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 > 0)
                {
                    ans += 1;
                }
                count /= 3;
                ans += count * 2;
            }
            else
            {
                ans++;
            }
        }

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

    public static int GetAns(char[] c,int N,List<string> list,int i)
    {
        if(i == N) return list.Count;

        int max = 0;
        for (int l = 1; l <= (N - i); l++)
        {
            string str = new string(c, i, l);
            if (list.Count > 0 && list[list.Count-1] == str) continue;
            var eList = new List<string>(list);
            eList.Add(str);
            int ans = GetAns(c, N, eList, i + l);
            if (max < ans)
            {
                max = ans;
            }
        }
        return max;
    }

    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();
    }

}
