Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n = int(input())
- stol = list(input())
- cnt = 0
- flag = True
- while len(stol) != 0:
- if flag:
- if stol[0] == 'm' and stol[-1] == 'c':
- stol.pop()
- stol.pop(0)
- elif stol[0] == 'm' or stol[-1] == 'c':
- if stol[0] == 'm':
- stol.pop(0)
- else:
- stol.pop()
- else:
- flag = False
- cnt +=1
- else:
- if stol[0] == 'c' and stol[-1] == 'm':
- stol.pop()
- stol.pop(0)
- elif stol[0] == 'c' or stol[-1] == 'm':
- if stol[0] == 'c':
- stol.pop(0)
- else:
- stol.pop()
- else:
- flag = True
- cnt += 1
- print(cnt)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement