Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.23 KB | None | 0 0
  1. n, mood = map(int, input().split())
  2. ans = 0; s = list(input().replace('B', ''))
  3. if mood < 0:
  4. ans += -mood
  5. mood = 0
  6. for i in s:
  7. if i == 'A':
  8. mood += 1
  9. else:
  10. if mood > 0:
  11. mood -= 1
  12. else:
  13. ans += 1
  14. print(ans)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement