You need 4 DFFs and some logic. (DFF is a data flip flop)
The logic look at the output of the FF and inputs a different number into the input of the FFs.
Logic: if 2 than 9, if 9 then 0, if 0 then 7, if 7 then 2.
>>only problem is that counter sometimes will not start up or gets locked and will not count.
Logic2: I would do it this way.
if 2 than 9, if 9 then 0, if 0 then 7, if (none of the above) then 2.
The improvement is that if the counter powered up with a 5 and the logic did not know what to do it might latch up.
Also if you are only looking for 2 or 9 or 0 then you are only looking for 3 states not 4. Might take less parts.