#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define INF_LL (ll)1e18 #define INF (int)1e9 #define REP(i, n) for(int i = 0;i < (n);i++) #define FOR(i, a, b) for(int i = (a);i < (b);i++) #define all(x) x.begin(),x.end() using ll = long long; using PII = pair; const double eps = 1e-10; templateinline void chmin(A &a, B b){if(a > b) a = b;} templateinline void chmax(A &a, B b){if(a < b) a = b;} struct RollingHash{ typedef unsigned long long ull; string S; ull B; vector hash,p; int len; RollingHash(){} RollingHash(string S,ull B=1000000007LL):S(S),B(B){init();}; void init(){ len=S.length(); hash.resize(len+1); p.resize(len+1); hash[0]=0;p[0]=1; for(int i=0;i mp; string s; int m; cin >> s; cin >> m; RollingHash rh(s); REP(i, s.size()){ for(int j = 0;j < 10 && i-j >= 0;j++){ mp[rh.find(i-j, i+1)]++; } } int res = 0; REP(i, m){ string a; cin >> a; RollingHash c(a); res += mp[c.find(0, a.size())]; } cout << res << endl; }