#include #include #include #include int main() { int n; std::cin >> n; std::list s; std::copy_n(std::istream_iterator(std::cin), n, std::back_inserter(s)); const auto is_AGCT = [](const char c) { return c == 'A' || c == 'G' || c == 'C' || c == 'T'; }; auto to_remove = std::count_if(s.cbegin(), s.cend(), is_AGCT); if (to_remove == 0) { std::cout << "0\n"; return 0; } auto iter = std::next(s.begin(), to_remove - 1); int res = 0; while (true) { bool f = is_AGCT(*iter); iter = s.erase(iter); ++res; if (f) { if (to_remove == 1) { break; } else { --to_remove; --iter; } } } std::cout << res << '\n'; }