import java.util.*;
import java.lang.*;
import java.io.*;
class Ideone {
Scanner in
= new Scanner
(System.
in); char table[] = new char[256];
int count[] = new int[256];
int tempcount[] = new int[256];
int templength,length,sum = 0,kilk,countwords = 0;
int mem = 0, index = 0;
word = in.nextLine();
kilk = in.nextInt();
for (int i = 0; i < kilk+1; i++) {
words[i] = in.nextLine();
}
length = word.length();
table[0] = word.charAt(0);
for (int i = 1; i < length; i++) {
for (int j = 0; j < i; j++) {
if (word.charAt(i) == table[j])
mem = 1;
}
if (mem == 0) {
index++;
table[index] = word.charAt(i);
}
mem = 0;
}
mem = 0;
for (int i = 0; i <= index; i++) {
for (int j = 0; j < length; j++) {
if (table[i] == word.charAt(j)) {
mem++;
}
}
count[i] = mem;
mem = 0;
}
int mem2 = 0;
for (int a = 0; a < kilk; a++) {
templength = words[a].length();
mem = 0;
for (int i = 0; i <= index; i++) {
for (int j = 0; j < templength; j++) {
if (table[i] == words[a].charAt(j)) mem++;
}
tempcount[i] = mem;
mem = 0;
}
for (int i = 0; i <= index; i++) sum = sum + tempcount[i];
mem2 = 0;
if (sum == templength) {
for (int i = 0; i <= index; i++) {
if (tempcount[i]>count[i])mem2++;
}
if (mem2 == 0) countwords++;
}
sum = 0;
}
System.
out.
println(countwords
); }
}