How to Calculate Backdoor outs

Dear Forum Members,
I am very confusing regarding one gapper and two gapper straight( Can we consider flop cards or hole cards only to determine one gap or two gap ) . I am particularly very confuse regarding outs calculation in the following quiz in Ace Poker Drills software.I have pasted hads history here.I used Advanced mode of Ace Poker Drills.


Board: 5sKc8h
Hero: JcQc
Opponent: 5h8d
Outs: 4
Odds: 16

Please any one of the forum members kindly explain how does 4 outs come ?

Thanks in advance
Regards,
Dr.P.Siva Ramakrishna