#include #include #include #include #include #include #include int main() { std::string str; std::cin >> str; auto N = str.size(); int M; std::cin >> M; int count = 0; std::maphash_count; for (std::size_t i = 0; i < N; ++i) { std::size_t hash = 0; for (std::size_t k = 0; i + k < N&&k < 10; ++k) { hash *= 27; hash += str[i + k] - 'A' + 1; ++hash_count[hash]; } } for (int i = 0; i < M; ++i) { std::string C; std::cin >> C; std::size_t hash = 0; for (auto c : C) { hash *= 27; hash += c - 'A' + 1; } count += hash_count[hash]; } std::cout << count << std::endl; }