8.7 Mad for Ice Cream
(RankList for this Question)
Score: 60pts
Time Limit: 1.00 sec
Deepali loves ice cream so her mom bought her some amount of ice cream cups. She bought two flavours of ice cream, mint chocolate chip and cookie cream. These cups were arranged in a randomized order. If she wanted to, Deepali could eat all of them at the same time but her mom set a condition for her. Her mom will keep some of these cups in different boxes, each box can store exactly 3 cups neither less nor more and all 3 cups should not be of the same flavour. From all the cups, she will take all consecutive cups such that without changing their order she could store them in different boxes. She will take the most number of cups that she can to prevent Deepali from eating all of them. Find out how many cups will Deepali be able to eat.

\(0 \leq \) number of icecream cups Deepali can eat \(\leq 1000\)

Input Format
The first and only line contains a string denoting the order in which the different ice cream cups are placed. M denotes mint chocolate chip and C denotes cookie cream.

Output Format
Print the number of ice cream cups that Deepali would be able to eat after her mom stores some of them in the boxes.

Example 1


The mom will take MMCMCC, she will store MMC in one box and MCC in the second box. So Deepali is left with 3 chocolates.

Example 2


The mom will take all the chocolates, she will store MMC in the first box, CMM in the second box and MCM in the third box. So Deepali cannot eat any chocolates.

Log In to solve the Question