Shelly Hassio push button counter

I’m using a Shelly 1 and I have it set up in home assistant. I’m using a toggle switch to turn it on and off. I want to use node red to count the number of times a switch is toggled and perform a certain task. Like a single toggle would turn on a light and a double would turn on another light and a triple toggle would turn everything off. How can it be done?