#include #include #include #pragma GCC optimize ("-O3") int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); std::string s; std::cin >> s; int m; std::cin >> m; long long answer = 0; for (auto i = 0; i < m; i++) { std::string c; std::cin >> c; auto pos = s.find(c, 0); while (pos != std::string::npos) { answer++; pos = s.find(c, pos + 1); } } std::cout << answer << std::endl; return EXIT_SUCCESS; }