Adding up values of variables

Hey guys, I got a rather complicated problem:

I have two variables, ID and Country

ID Country
11 US
11 KR
11 CA
23 US
23 US
23 US
25 CA
25 JP
31 CA
31 CA

What I want to do now is to figure out the different number of countries per ID. for ID 11 the number would be three, since we have US, KR and CA.

Does anyone know how to solve this by programming?