Place down a relay, a wire repeater, and a counter. Wire the relay to the counter, and select “relay triggers” and “reset counter”. It is VERY IMPORTANT that you do this step first. Then, wire the relay to the wire repeater, and the wire repeater to the counter. Select “increment counter.” It is VERY IMPORTANT that you do this step second.
If you’re curious about why the order of the wires is important, here’s something that explains that: