from sys import stdin, setrecursionlimit readline = stdin.readline base = 37; mod = 10**9 + 9 pw = None def rolling_hash(s): l = len(s) h = [0]*(l + 1) v = 0 for i in range(l): h[i+1] = v = (v * base + ord(s[i])) % mod return h # RH前に、必要な長さの最大値分のpow-tableを計算しておく def setup_pw(l): global pw pw = [1]*(l + 1) v = 1 for i in range(l): pw[i+1] = v = v * base % mod def get(h, l, r): return (h[r] - h[l] * pw[r-l]) % mod setup_pw(5*10**4) S=input() M=int(input()) A=rolling_hash(S) ans=0 for i in range(M): T=input() B=rolling_hash(T)[-1] for j in range(len(S)-len(T)+1): d=get(A,j,j+len(T)) if d==B: ans+=1 #print(d,j,j+len(T)) print(ans)