#include //#include //using namespace atcoder; using namespace std; using ll = long long; using vll = vector; using vvll = vector; using vvvll = vector; #define all(A) A.begin(),A.end() #define rep(i, n) for (ll i = 0; i < (ll) (n); i++) using pqr = priority_queue, vector>, greater>>; vector fact, factinv, inv; ll mod = 998244353; void prenCkModp(ll n) { fact.resize(n + 5); factinv.resize(n + 5); inv.resize(n + 5); fact.at(0) = fact.at(1) = 1; factinv.at(0) = factinv.at(1) = 1; inv.at(1) = 1; for (ll i = 2; i < n + 5; i++) { fact.at(i) = (fact.at(i - 1) * i) % mod; inv.at(i) = mod - (inv.at(mod % i) * (mod / i)) % mod; factinv.at(i) = (factinv.at(i - 1) * inv.at(i)) % mod; } } ll nCk(ll n, ll k) { if (n < k) return 0; return fact.at(n) * (factinv.at(k) * factinv.at(n - k) % mod) % mod; } bool chmax(ll& p, ll q) { if (p < q) { p = q; return 1; } else { return 0; } } bool chmin(ll& p, ll q) { if (p > q) { p = q; return 1; } else { return 0; } } ll sti(string S) { ll res = 0; rep(i, S.size()) { res += S[i] - '0'; res *= 10; } return res / 10; } string ist(ll n, ll L) { string res = ""; rep(l, L)res += '0'; ll p = L - 1; while (n > 0) { res[p] = char(n % 10 + '0'); p--; n /= 10; } return res; } ll gcd(ll(a), ll(b)) { ll c = a; while (a % b != 0) { c = a % b; a = b; b = c; } return b; } struct rollinghash{ const ll base=9973; const vector MoD = {999999937, 1000000007}; string S; vector hash[2], power[2]; rollinghash(const string &cs) { init(cs); } ll Shash(string T,ll iter){ ll n = T.size(); ll reshash=0; ll respow=1; rep(i,n){ reshash = (reshash*base + T[i]) % MoD[iter]; } return reshash; } void init(const string &cs) { S = cs; ll n = S.size(); rep(iter,MoD.size()) { hash[iter].assign(n+1, 0); power[iter].assign(n+1, 1); rep(i,n) { hash[iter][i+1] = (hash[iter][i] * base + S[i]) % MoD[iter]; power[iter][i+1] = power[iter][i] * base % MoD[iter]; } } } ll get(int l, int r, int id = 0) const { return ((hash[id][r] - (hash[id][l] * power[id][r-l]) % MoD[id])+MoD[id])%MoD[id]; } ll getLCP(int a, int b) const { int len = min((int)S.size()-a, (int)S.size()-b); int low = -1, high = len + 1; while (high - low > 1) { int mid = (low + high) / 2; if (get(a, a+mid, 0) != get(b, b+mid, 0)) high = mid; else if (get(a, a+mid, 1) != get(b, b+mid, 1)) high = mid; else low = mid; } return low; } }; int main() { //cin.tie(nullptr); //ios::sync_with_stdio(false); string S; cin>>S; rollinghash rh(S); ll N=S.size(); ll M; cin>>M; ll an=0; vector> D(S.size()+1); rep(m,M){ string T; cin>>T; ll P=T.size(); ll CH=rh.Shash(T,0); if(NN)break; ll CB=rh.get(i,i+P); D[P][CB]++; } an+=D[P][CH]; } cout<