#include using namespace std; #define int long long #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) #define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--) #define itn int #define all(x) (x).begin(),(x).end() #define F first #define S second const long long INF = 1LL << 60; const int MOD = 1000000007; struct KMP{ vector table; string p; int sz; KMP(string S){ //探したいword, pattern sz = S.size(); p = S; table.resize(sz+1); int j = table[0] = -1; for (int i = 0; i < S.size(); i++) { while (j >= 0 && S[i] != S[j]) j = table[j]; j++; //table[i+1] = j; if (S[i+1] == S[j]) table[i+1] = table[j]; else table[i+1] = j; } //rep(i, table.size()) cout<>*/ int findfrom(string &t) { //text int n = t.size(); int count = 0; //vector > data; for (int i = 0, k = 0; i < n; ++i) { while (k >= 0 && p[k] != t[i]) k = table[k]; if (++k >= sz) { //data.push_back({i-sz+1,i}); k = table[k]; count++; } } return count; //return data; //0indexed } }; signed main(void){ string text; cin>>text; int n; cin>>n; int ans = 0; rep(i,n){ string tmp; cin>>tmp; KMP kmp(tmp); int cnt = kmp.findfrom(text); //cout<