Advertisement
Guest User

1

a guest
Oct 16th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. n, k = map(int, input().split())
  2. count_of_chocolade = 0
  3. if k < 0:
  4. count_of_chocolade += abs(k)
  5. k = 0
  6. stroke = input()
  7. for elem in stroke[:-1]:
  8. if elem == "A":
  9. k += 1
  10. elif elem == "C":
  11. if k == 0:
  12. count_of_chocolade += 1
  13. else:
  14. k -= 1
  15. if k < 0:
  16. count_of_chocolade += abs(k)
  17. print(count_of_chocolade)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement