Question
String Split

Ria has a string S of length M. She wants to split it into non‑empty, consecutive pieces

S₁, S₂, …, SL

such that

  1. S₁+S₂+…+SL = S

  2. For every i>1, Sᵢ ≠ Sᵢ₋₁

  3. L is as large as possible

Input
The first line of the input contains a single integer M.
The second line of the input contains a string S of length M.

Output
Print the maximum such integer L which satisfies the above conditions.
Example
Sample Input
6
xxyyxx
Sample Output
4
Explanation
We can divide this string into: xx, y, yx, x.

Online