Minecraft wiki entry for Pulse, associated text: Use as a binary counter requires reading position of the blocks moved by the pistons, e.g. through repeaters one block above the 'rest' position.
If the input has mixed length pulses, both 1-tick and longer, set the first repeater to 2 ticks and treat the first piston as pulse limiter, not counter module.