#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define MAX_MOD 1000000007 #define REP(i,n) for(long long i = 0;i < n;++i) #define LONGINF 1000000000000000000 map woow; int main() { ios::sync_with_stdio(false); string s; cin >> s; int kazu; cin >> kazu; REP(i, kazu) { string aaa; cin >> aaa; woow[aaa] += 1; } long long ans = 0; for (int i = 0;i < s.length();++i) { string www; for (int q = i;q < i + 10 && q < s.length();++q) { www.push_back(s[q]); ans += woow[www]; } } cout << ans << endl; return 0; }