Advertisement
phoenix123565632

B1,B2

Oct 17th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. n,k=map(int,input().split())
  2.  
  3. line=input()
  4.  
  5. pos=k
  6. f=0
  7.  
  8. if pos < 0:
  9. f = - pos
  10. pos = 0
  11.  
  12. for i in range(n-1):
  13. ig=line[i]
  14.  
  15. if ig=='C':
  16. pos-=1
  17. if ig=='A':
  18. pos+=1
  19.  
  20. if pos<0:
  21. f+=1
  22. pos=0
  23. print(f)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement