Set History stats to track ANY STATE

Is there any way to count all state changes of a variable?

This is my situation: I have an input_button (pushed with an Alexa routine) and I want to count how many time it’s pushed in last 24 h

sensor:
  - platform: history_stats
    name: Pushes in 24h
    entity_id: input_button.push_me
    state: 'on'
    type: count
    end: "{{ now() }}"
    duration:
      hours: 24

But the state of an input_button is the timestamp (i.e. 2022-12-12T20:11:58.861550+00:00).

I can change the input_button with a toggle “turn on” + “turn off” but it’s an antiestetical workaround.

Buttons are stateless.

Another way to do this would be an automation that increments a counter when the button is pushed. And another automation to reset the counter at midnight.

I also thinked that but in this way you have “today” count and not “last 24 h” count.

I’ll use toggle ugly solution