Create sensor count esphome

hello how do I create a sensor on esphome that will count the number of GPIO connections and disconnections? I do not need in time the result should be just a number. Respectively the number of pieces. well thank you

https://esphome.io/components/sensor/pulse_counter.html#counting-total-pulses