#include #include #include #include #include #include #include #include using namespace std; int main() { string s; cin >> s; int m; cin >> m; int ans = 0; for (int i = 0; i < m; i++) { string target; cin >> target; int hash = 0,target_hash=0; for (int i = 0; i < target.size(); i++) target_hash += (target[i] - 'A'+1)*pow(26, i); for (int i = 0; i < target.size(); i++) hash += (s[i] - 'A'+1)*pow(26, i); if (hash == target_hash)ans++; for (int i = target.size(); i < s.size(); i++) { hash -= (s[i - target.size()] - 'A' + 1); hash /= 26; hash += (s[i] - 'A' + 1)*pow(26, target.size() - 1); if (hash == target_hash)ans++; } } cout << ans << endl; return 0; }