public class 掌握的单词个数 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = Integer.parseInt(in.nextLine());
String[] words = new String[n];
int signalCount = 0;
int[] chars = new int[26];
for (int i = 0; i < n; i++) {
words[i] = in.nextLine();
}
String str = in.nextLine();
for (int i = 0; i < str.length(); i++) {
if ('?' == str.charAt(i)) {
signalCount++;
} else {
int x = str.charAt(i) - 'a';
chars[x]++;
}
}
int count = 0;
for (String word : words) {
count += Count(word, chars, signalCount);
}
System.out.println(count);
}
//判断单词word能否被拼出来
public static int Count(String word, int[] chars, int signalCount) {
int[] arr = chars.clone();//要复制chars数组,不能修改他
boolean flag = true;
for (int i = 0; i < word.length(); i++) {
int x = word.charAt(i) - 'a';
if (arr[x] > 0) {
arr[x]--;
} else if (signalCount > 0) {
signalCount--;
} else {
flag = false;
break;
}
}
if (flag) {
return 1;
} else {
return 0;
}
}
}