//#include #include "bits/stdc++.h" using namespace std; typedef long long ll; //#include "boost/multiprecision/cpp_int.hpp" //typedef boost::multiprecision::cpp_int ll; typedef long double dd; #define i_7 (ll)(1E9+7) //#define i_7 998244353 #define i_5 i_7-2 ll mod(ll a){ ll c=a%i_7; if(c>=0)return c; return c+i_7; } typedef pair l_l; ll inf=(ll)1E16; #define rep(i,l,r) for(ll i=l;i<=r;i++) #define pb push_back ll max(ll a,ll b){if(ab)return b;else return a;} void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]); void Min(ll &pos,ll val){pos=min(pos,val);} void Add(ll &pos,ll val){pos=mod(pos+val);} dd EPS=1E-9; #define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define fi first #define se second //////////////////////////// string s,t; ll p1=1009; ll po(ll i,ll p){ if(p==0)return 1; else{ i=mod(i); if(p==1)return i; if(p%2==0)return po(mod(i*i),p/2); return mod(i*po(i,p-1)); } } ll bunbo(ll n){ return po(n,i_5); } int main(){fastio cin>>s; ll m;cin>>m; ll n=s.size(); ll a[n+1]; a[0]=0; rep(i,0,n-1){ a[i+1]=po(p1,i)*s[i]; Add(a[i+1],a[i]); } ll bun[n]; rep(i,0,n-1){ bun[i]=bunbo(po(p1,i)); } ll ans=0; while(m--){ cin>>t; ll b=0; ll ts=t.size(); rep(i,0,ts-1){ Add(b,po(p1,i)*t[i]); } rep(i,0,n-1){ ll j=i+ts; if(j>n)continue; ll sum=mod(a[j]-a[i])*bun[i]; if(mod(sum-b)==0)ans++; } //cout<