counting problem

I need the check being continuously while there is a state of the counting equal to zero. In the same time, I need counting value returns to zero each time the loop starts.

Basically, the idea is simple, there three LEDs:

Green when the counting is less than 5 and more than 0
yellow when the counting is less than 8 and more than 4
red when the counting is more than 7