Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n, mood = map(int, input().split())
- ans = 0; s = list(input().replace('B', ''))
- if mood < 0:
- ans += -mood
- mood = 0
- for i in s:
- if i == 'A':
- mood += 1
- else:
- if mood > 0:
- mood -= 1
- else:
- ans += 1
- print(ans)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement