#include #include using namespace std; int main() { string s, t, k; int ans = 0, m, w; unordered_set us; cin >> s >> m; for (int i = 0; i < m; ++i) { cin >> t; us.insert(t); } for (int i = 0; i < s.size(); ++i) { k = ""; w = s.size() - i > 9 ? 10 : s.size() - i; for (int j = 0; j < w; ++j) { k += s[i + j]; if(us.find(k) != us.end()){ ++ans; } } } cout << ans << endl; return 0; }