L=50000 B=123451234512345 M=(1<<61)-1 P=[1,B] R=[1,pow(B,M-2,M)] for i in range(2,L+1): P+=[P[-1]*P[1]%M] R+=[R[-1]*R[1]%M] class RH(): def __init__(self,s): self.len=len(s) self.h=[0]*(len(s)+1) for i in range(self.len): self.h[i]=(ord(s[i])*P[i]+self.h[i-1])%M return def rh(self,l,r): return (self.h[r]-self.h[l-1])*R[l]%M S=RH(input()) L=S.len n=int(input()) c=0 for _ in range(n): t=RH(input()) l=t.len for i in range(L-l+1): c+=S.rh(i,i+l-1)==t.rh(0,l-1) print(c)