#include <stdio.h>
#include <limits.h>
#include <string.h>
#include <ctype.h>
char *gets(char *str);
//char gets(char str);
char N[25];
char gohell[1000];
int A[25];
char x,o;
int main(void){
int n,t=0;
scanf("%s",N);
n=strlen(N);
for(int i=0;i<n;i++){
if(islower(N[i]))
A[i]=(int)N[i]-96;
else if(isupper(N[i]))
A[i]=(int)N[i]-40;
}
while(x=getchar()!=EOF){
if(x==' ' || x=='\n' || x=='-' || x=='/' || x==':' || x=='(' || x==')' || x=='[' || x==']' || x==',' || x=='.'){
for(int i=1;i<n;i++){
o++;
x=getchar();
if((int)x==(A[0]+40) || (int)x==(A[0]+96)){
break;
}
}
if(o!=n+1) break;
x=getchar();
if(x==' ' || x=='\n' || x=='-' || x=='/' || x==':' || x=='(' || x==')' || x=='[' || x==']' || x==',' || x=='.'){
t++;
}
}
}
printf("%d\n",t);
return 0;
}