Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- long int a,b,res=0;
- string s;
- map<char,int> dict;
- int main()
- {
- cin >> a >> b >> s;
- dict['B'] = 0;
- dict['A'] = 1;
- dict['C'] = -1;
- for(auto i:s){
- if(b<0){
- res = 0-b;
- b=0;
- }
- b+= dict[i];
- }
- cout << res;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement