Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- kolvo, nastroenie = map(int, input().split())
- st = list(input())
- #st = list(filter(lambda a: a != 'B', st))
- if nastroenie >= 0:
- cho = 0
- else:
- cho = -nastroenie
- nastroenie = 0
- for i in range(len(st)):
- if st[i] == 'A':
- nastroenie += 1
- elif st[i] == 'C':
- nastroenie -= 1
- #print(nastroenie)
- if nastroenie < 0 and i != len(st) - 1:
- cho += 1
- nastroenie += 1
- # if st[-1] == 'C' and cho != 0:
- # print(cho - 1)
- # else:
- print(cho)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement