The actual issue is different I guess.

The system used is IDPPM - Differential Pulse Position Modulation.
Now I changed algorithm, and it detects pulses, there are 34 pulses, and it does it properly. But quantity of pulses is always 34, only pauses between them change, so COUNT is not proper implementation I guess.

P.S. above code displays only 00000