Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. n = int(input())
  2. stol = list(input())
  3. cnt = 0
  4. flag = True
  5. while len(stol) != 0:
  6. if flag:
  7. if stol[0] == 'm' and stol[-1] == 'c':
  8. stol.pop()
  9. stol.pop(0)
  10. elif stol[0] == 'm' or stol[-1] == 'c':
  11. if stol[0] == 'm':
  12. stol.pop(0)
  13. else:
  14. stol.pop()
  15. else:
  16. flag = False
  17. cnt +=1
  18. else:
  19. if stol[0] == 'c' and stol[-1] == 'm':
  20. stol.pop()
  21. stol.pop(0)
  22. elif stol[0] == 'c' or stol[-1] == 'm':
  23. if stol[0] == 'c':
  24. stol.pop(0)
  25. else:
  26. stol.pop()
  27. else:
  28. flag = True
  29. cnt += 1
  30. print(cnt)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement