I have my project setup to check for button presses on a pin. Simple IF *** = 0 THEN ****

I would like to be able to count the button presses like if 3 button presses are made within a certain time, it would set a variable to 3. If pressed 5 times, set said variable to 5 and so on.

Right now my code is setup to just add to the current variable every time the button is pressed. The problem is that I have it flash an LED to confirm what setting it's on and since it immediately add's to the variable, then checks the variable, you can't just tap the button 4 quick times and jump to setting 4.

Any help would be great.