atcoder#AGC037A. [AGC037A] Dividing a String

[AGC037A] Dividing a String

Score : 300300 points

Problem Statement

Given is a string SS consisting of lowercase English letters. Find the maximum positive integer KK that satisfies the following condition:

  • There exists a partition of SS into KK non-empty strings S=S1S2...SKS=S_1S_2...S_K such that SiSi+1S_i \neq S_{i+1} (1iK11 \leq i \leq K-1).

Here S1S2...SKS_1S_2...S_K represents the concatenation of S1,S2,...,SKS_1,S_2,...,S_K in this order.

Constraints

  • 1S2×1051 \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 positive integer KK that satisfies the condition.

aabbaa
4

We can, for example, divide SS into four strings aa, b, ba, and a.

aaaccacabaababc
12