#include #include #include using namespace std; #define StrLen(str) ((sizeof(str)/sizeof(str[0]))-1) int nSubstr(const string &str, const string &sub) { int n = 0, idx = 0; while (true) { while (str[idx] != sub[0]) ++idx; if (idx > str.size()) break; if (sub.size() == 1) { ++n; ++idx; continue; } bool found = true; for (int i = 1; i < sub.size(); ++i) { if (str[idx + i] != sub[i]) { found = false; break; } } if (found) ++n; ++idx; } return n; } int main () { int count = 0; string str; vector subs; int n; cin >> str; cin >> n; for (int i = 0; i < n; ++i) { string tmp; cin >> tmp; subs.push_back(tmp); } for (string sub : subs) { count += nSubstr(str, sub); } cout << count << endl; }