from collections import defaultdict as df class trie: def __init__(self): self.exist = 0 self.kodomo = df(trie) def add(self,moji): now = ne for i in moji: now = now.kodomo[i] now.exist += 1 def find(self,moji): now = ne for i in moji: if not now.kodomo[i]: return False now = now.kodomo[i] return now.exist s=input() ne = trie() for i in range(len(s)): t='' for j in range(i,min(i+10,len(s))): t+=s[j] ne.add(t) q=int(input()) ans = 0 for i in range(q): t = input() ans += ne.find(t) print(ans)