Advertisement
OIQ

Da

OIQ
Oct 15th, 2019
167
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.30 KB | None
  1. import math
  2. n, k = map(int, input().split())
  3. s = input()
  4. count = 0
  5. if k < 0:
  6.     count += int(math.fabs(k))
  7.     k = 0
  8.  
  9. for i in s:
  10.     if k == -1:
  11.         count += 1
  12.         k += 1
  13.     if i == 'A':
  14.         k += 1
  15.     elif i == 'B':
  16.         continue
  17.     else:
  18.         k -= 1
  19. print(count)
Advertisement
RAW Paste Data Copied
Advertisement