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