#arc113c. [arc113_c]String Invasion

[arc113_c]String Invasion

Problem Statement

Given is a string SS of length NN. Let sis_i denote the ii-th character of SS. Find the maximum number of times the following operation can be done.

  • Choose three consecutive characters in SS, si,si+1,si+2quad(1leqileqS2)s_i,s_{i+1},s_{i+2}\\quad (1\\leq i\\leq |S|-2), such that si=si+1neqsi+2s_i=s_{i+1}\\neq s_{i+2}, and replace si+2s_{i+2} with sis_i.

Constraints

  • 3leqSleq2times1053 \\leq |S| \\leq 2\\times 10^5
  • SS consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

SS

Output

Print the maximum number of times the operation can be done.


Sample Input 1

accept

Sample Output 1

3

We can do the operation three times, as follows:

  • do it with i=2i=2, changing the string to acccpt;
  • do it with i=3i=3, changing the string to acccct;
  • do it with i=4i=4, changing the string to accccc.

Sample Input 2

atcoder

Sample Output 2

0

Sample Input 3

anerroroccurred

Sample Output 3

16