I have a custom list button on contact with behavior as shown below:

And this custom button is added to the contact related list on account

When I select 2 or more contacts and click on custom button, it redirects me to the visualforce page with the selected contacts and everything looks good. I am trying to put a validation (may be javascript alert message) that before redirecting to visualforce page, atleast 2 contacts are selectes.
Here is my visualforce page:
<apex:page standardController="Contact" recordSetVar="Contacts">
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!selected}" var="con">
<apex:column value="{!con.name}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Thanks