Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. kolvo, nastroenie = map(int, input().split())
  2. st = list(input())
  3. #st = list(filter(lambda a: a != 'B', st))
  4. if nastroenie >= 0:
  5.     cho = 0
  6. else:
  7.     cho = -nastroenie
  8.     nastroenie = 0
  9.  
  10. for i in range(len(st)):
  11.     if st[i] == 'A':
  12.         nastroenie += 1
  13.     elif st[i] == 'C':
  14.         nastroenie -= 1
  15.         #print(nastroenie)
  16.     if nastroenie < 0 and i != len(st) - 1:
  17.         cho += 1
  18.         nastroenie += 1
  19. # if st[-1] == 'C' and cho != 0:
  20. #     print(cho - 1)
  21. # else:
  22. print(cho)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement