S = input() N = len(S) M = int(input()) base = 100 MOD = 10**9 + 7 pw = [1] for i in range(N): pw.append(pw[-1]*base % MOD) hashtable = [0] for i in range(N): hashtable.append((hashtable[-1]*base + ord(S[i])-ord("a"))%MOD) #print(hashtable) res = 0 for _ in range(M): s = input() LEN = len(s) if LEN > N: continue s_hash = [0] for i in range(LEN): s_hash.append((s_hash[-1]*base + ord(s[i])-ord("a"))%MOD) tmp1 = s_hash[-1] #print(s,tmp1) for i in range(N-LEN+1): tmp2 = (hashtable[LEN+i] - hashtable[i]*pw[LEN]) % MOD if tmp2 == tmp1: #print(tmp2,tmp1,i,s) res += 1 print(res)