using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

class AtCoder
{
    const int MOD = 1000000007;
    public void Slove()
    {
        var str = Console.ReadLine();
        char[] bef = new char[2];
        bef[0] = str.First();
        var dp = Enumerable.Range(0, str.Length)
            .Select(x => new int[2])
            .ToArray();
        foreach(int i in str.Select((x, index) => index).Skip(1))
        {
            char c = str[i];
            if (bef[0] != c)
            {
                dp[i][0] = dp[i - 1][0] + 1;
            }
            if(i > 1)
            {
                dp[i][0] = Math.Max(dp[i][0], dp[i - 2][1] + 1);
                dp[i][1] = dp[i - 1][0] + 1;
            }
            if(i > 2)
            {
                if (bef[0] != bef[1] || bef[0] != c)
                {
                    dp[i][1] = Math.Max(dp[i][1], dp[i - 2][1] + 1);
                }
            }
            //Console.WriteLine(c + string.Join("", bef));
            bef[1] = bef[0];
            bef[0] = c;
            //Console.WriteLine(string.Join(" ", dp[i]));
        }
        Console.WriteLine(dp[str.Length - 1].Max() + 1);
    }
    static void Main()
    {
        var ac = new AtCoder();
        ac.Slove();
    }
}