/*****API层数识别单词次数*****/
#include <stdio.h>
#include <string.h>
int main() {
int n = 0;
int cnt=0;
char str[100][10][11] = {0};
scanf("%d", &n);
for (int i = 0; i < n; i++) {
char temp[111] = {0};
scanf("%s", temp);
char *p=temp;
int m=0;
while(p= strtok(p,"/")){
strcpy(str[i][m++],p);
p=NULL;
}
}
int layer=0;
char words[11]={0};
scanf("%d %s",&layer,words);
for(int i=0;i<n;i++){
if(!strcmp(str[i][layer-1],words)){
cnt++;
}
}
printf("%d",cnt);
}