Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <string>
- #include <algorithm>
- #include <cmath>
- int main() {
- #ifdef LOCAL
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- int n, k;
- std::cin >> n >> k;
- int min = 0, now = 0;
- std::string s;
- std::cin >> s;
- if (s.back() == 'C')
- s.pop_back();
- for (auto a : s) {
- if (a == 'A') {
- now++;
- } else if (a == 'C') {
- now--;
- min = std::min(now, min);
- }
- }
- if (min + k >= 0)
- std::cout << 0;
- else
- std::cout << -(min + k);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement