#include using namespace std; typedef long long ll; #define all(x) (x).begin(),(x).end() const int mod=1000000007,MAX=1003,INF=1<<30; int dp[MAX][53][53]; struct KMP{ vector A; string S; void init(string &T){ S=T; A.assign(S.size()+1,0); A[0]=-1; int j=-1; for(int i=0;i=0&&S[i]!=S[j]) j=A[j]; j++; A[i+1]=j; } } vector match(string &T){ vector B; int m=0,i=0; while(m+i0) i=A[i]; } } return B; }//Tの中にSが含まれる開始位置を返す }; int main(){ std::ifstream in("text.txt"); std::cin.rdbuf(in.rdbuf()); cin.tie(0); ios::sync_with_stdio(false); string S;cin>>S; int M;cin>>M; ll sum=0; while(M--){ string T;cin>>T; KMP k; k.init(T); sum+=k.match(S).size(); } cout<