SHARE
TWEET

Untitled

a guest Oct 16th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top