using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{

    static void Main(string[] args)
    {
        char[] c = Console.ReadLine().ToCharArray();
        int N = c.Length;

        int ans = 0;
        for (int i = 0; i < N; i++)
        {
            if (i + 1 != N && c[i] == c[i + 1])
            {
                int count = 1;
                int j = i + 1;
                for (; j < N; j++)
                {
                    if(c[i] == c[j])
                    {
                        count++;
                    }
                    else
                    {
                        break;
                    }
                }
                i = j-1;
                
                if (count%3 == 2)
                {
                    if (i + 1 != N)
                    {
                        if (i + 2 == N)
                        {
                            ans += 2;
                            break;
                        }else if(c[i+1] == c[i + 2])
                        {
                            ans += 2;
                            i = i + 1;
                        }
                    }
                    else
                    {
                        ans += 1;
                    }
                }
                else if(count % 3 == 1)
                {
                    ans += 1;
                }
                count /= 3;
                ans += count * 2;
            }
            else
            {
                ans++;
            }
        }

        Console.Write(""+ ans);
        Console.ReadKey();
    }

    public static int GetInputInt()
    {
        return int.Parse(Console.ReadLine());
    }
    public static int[] GetInputsInt()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }
    public static List<int> GetInputsIntList()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToList();
    }
    public static long GetInputLong()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] GetInputsLong()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }

}
