import sys S = list(input()) M = int(input()) def Rolling_hash(T,mod = None,base_num=None): S = [ord(i) for i in T] N = len(S) if mod is None: mod = 3000012541 if base_num is None: base_num = 10007 H = [0]*(N+1) b_inv = [1]*N tb = base_num tb_inv = 1 base_inv = pow(base_num,mod-2,mod) tH = S[0] H[1] = tH for i in range(N-1): tH = (tH + S[i+1]*tb)%mod H[i+2] = tH tb = (tb*base_num)%mod tb_inv *= base_inv tb_inv %= mod b_inv[i+1] = tb_inv return b_inv,H mod = 3000012541 ans = 0 N = len(S) b_inv,T = Rolling_hash(S) for _ in range(M): C = list(input()) n = len(C) _,hC = Rolling_hash(C) target = hC[n] - hC[0] for i in range(N-n+1): if target == (b_inv[i]*(T[i+n] - T[i]))%mod: ans += 1 print(ans)