#include #define rep(i, n) for (int i = 0; i < (n); ++i) #define rrep(i, n) for (int i = (n)-1; i >= 0; i--) #define rep2(i, s, n) for (int i = (s); i < (n); ++i) #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() #define pb push_back #define eb emplace_back #define vi vector #define vvi vector> #define vl vector #define vvl vector> #define vd vector #define vs vector #define vc vector #define vb vector #define vp vector

using namespace std; using ll = long long; using P = pair; using LP = pair; template istream &operator>>(istream &is, pair &p) { return is >> p.first >> p.second; } template ostream &operator<<(ostream &os, const pair &p) { return os << '{' << p.first << "," << p.second << '}'; } template istream &operator>>(istream &is, vector &v) { for (T &t:v) { is >> t; } return is; } template ostream &operator<<(ostream &os, const vector &v) { os << '['; rep(i, v.size())os << v[i] << (i == v.size() - 1 ? ']' : ','); return os; } void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; } void YES(bool b) { cout << (b ? "YES" : "NO") << endl; } template bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } const int inf = 1001001001; const ll linf = 1001001001001001001; template struct Node { vi next; int accept; int c; Node(int c) : next(char_size, -1), accept(0), c(c) {} }; template class trie { using node = Node; vector nodes; public: trie() { nodes.pb(node(0)); } void insert(const string &s) { int pos = 0; rep(i, s.size()) { int c = (int) s[i] - base; int &next = nodes[pos].next[c]; if (next == -1) { next = nodes.size(); nodes.pb(node(c)); } pos = next; } nodes[pos].accept++; } int count(const string &s) { int pos = 0; rep(i, s.size()) { int c = (int) s[i] - base; int &next = nodes[pos].next[c]; if (next == -1) { return 0; } pos = next; } return nodes[pos].accept; } }; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); string s; int m; cin >> s >> m; trie<26, int('A')> tr; rep(_, m) { string c; cin >> c; tr.insert(c); } int ans = 0; rep2(i, 1, min(10,(int)s.size())+1) rep(j, s.size() - i + 1) { ans += tr.count(s.substr(j, i)); } cout << ans << endl; }