Counting teeth, and skipping pulses

It is fairly difficult to do with the gates.

I would use a 8pdip avr and program it for that.