#include<bits/stdc++.h>
using namespace std;
int main() {
string str;
while(getline(cin,str)) {
string s;
string words[100];
getline(cin,s);
int index=0;
int k=0;
for(int i=0,n=s.size(); i<n; i++) {
if(isalpha(s[i]) and !isalpha(s[i+1]) ) {
words[k++]=s.substr(index,i-index+1);
index=i+1;
} else if(!isalpha(s[i])) {
index++;
}
}
int sum=0;
for(int i=0; i<=k; i++) {
words[i][0]=tolower(words[i][0]);
str[0]=tolower(str[0]);
if(words[i]==str) {
sum++;
}
}
cout<<sum<<endl;
}
return 0;
}