#include"bits/stdc++.h"
#define int long long
using namespace std;
inline int read(){
int xr = 0, f = 1;
char cr;
while (cr = getchar(), cr < '0' or cr > '9'){
if (cr == '-'){
f = -1;
}
}
while (cr >= '0' and cr <= '9')
{
xr = (xr << 3) + (xr << 1) + (cr xor 48);
cr = getchar();
}
return xr * f;
}
int n, used[2010];
string s, words[2010];
int ans;
signed main(){
n = read();
for(int i = 1; i <= n; ++ i){
cin >> words[i];
transform(words[i].begin(),words[i].end(),words[i].begin(),::tolower);
}
getchar();
getline(cin, s);
transform(s.begin(),s.end(),s.begin(),::tolower);
string aword = "";
for(int i = 1; i < s.size(); ++ i){
if(s[i] == '.'){
for(int j = 1; j <= n; ++ j){
if(aword == words[j] && !used[j]){
ans ++;
break;
}
}
aword = "";
memset(used, 0, sizeof used);
continue;
}else if(s[i] == ' ' || s[i] == ','){
for(int j = 1; j <= n; ++ j){
if(aword == words[j] && !used[j]){
ans ++;
used[j] ++;
break;
}
}aword = "";continue;
}else aword += s[i];
}
cout << ans;
return 0;
}
话说为甚测试点4是大话西游啊