#include using namespace std; typedef long long ll; #define ft first #define sd second #define fr(i,n) for(int i=0;i<(n);++i) #define Fr(i,n) for(int i=1;i<=(n);++i) #define ifr(i,n) for(int i=(n)-1;i>=0;--i) #define iFr(i,n) for(int i=(n);i>0;--i) template struct RH{ using u64 = uint_fast64_t; size_t n=0; vector hsh,pwr; RH(){} explicit RH(string& s){ n=s.length(); hsh.resize(n+1); pwr.resize(n+1); pwr[0]=1; for(size_t i=0;i=mod) a-=mod; return a; } u64 connect(u64 h1,u64 h2,size_t l)const{ return (h1*pwr[l]+h2)%mod; } bool match(RH& b,size_t l1){ if(l1+b.n>n) return false; return get(l1,l1+b.n)==b.get(0,b.n); } }; struct RHs{ using u64 = uint_fast64_t; using a3 = array; static const u64 mod1=1000000007; static const u64 mod2=1000000009; static const u64 mod3=998244353; static const u64 base1=10009; static const u64 base2=10037; static const u64 base3=10007; size_t n; RH rh1; RH rh2; RH rh3; explicit RHs(string& s){ n=s.length(); rh1=RH(s); rh2=RH(s); rh3=RH(s); } a3 get(size_t l,size_t r)const{ return a3({rh1.get(l,r),rh2.get(l,r),rh3.get(l,r)}); } a3 connect(a3 h1,a3 h2,size_t l){ return a3({rh1.connect(h1[0],h2[0],l),rh2.connect(h1[1],h2[1],l),rh3.connect(h1[2],h2[2],l)}); } bool match(RHs& b,size_t l1){ if(l1+b.n>n) return false; return get(l1,l1+b.n)==b.get(0,b.n); } size_t LCP(RHs& b,size_t l1,size_t r1,size_t l2,size_t r2){ int len=min(r1-l1,r2-l2); int l=-1,r=len+1,m; while(r-l>1){ m=(l+r)/2; if(get(l1,l1+m)==b.get(l2,l2+m)) l=m; else r=m; } return (size_t)l; } }; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); string s,c; cin>>s; using rh=RH<1000000007,10009>; rh rs(s); int m,ans=0; cin>>m; fr(_,m){ cin>>c; rh rc(c); fr(i,rs.n) if(rs.match(rc,i)) ++ans; } cout<