What is the best method of counting button pushes for a 'Mode' Select.

I have three buttons which are used in a SELECT CASE routine.

What i would like is say when button 2 is pushed this then sets a MODE.

Then depending on the amount of times that button is pushed within a three second period, defines what happens next.

So from the start, pushing button 2 once goes to routine 1, pushing it twice goes to routine 2 and pushing 3 times goes to routine 3.

What is the most reliable method of doing this, anyone used this kind of taks before in a project.

Many thanks.