using System;
class ProgramA
    {
        static void Main(string[] args)
        {
            
            string s = Console.ReadLine();

            string now = "";
            string pre= "";
            int count_s = 1;
            int count_d = 1;
            int sum = 0;
            int frag = 0;

            for(int i = 1;i < s.Length;i++)
            {
                now = s.Substring(i,1);
                pre = s.Substring(i-1,1);
                if(pre == now)
                {
                    if(count_d > 1)
                    {
                        sum += count_d -1;
                        count_s = 2;
                        count_d = 0;
                    }
                    else
                    {
                        count_s++;
                    }

                    if(i == s.Length - 1)
                    {
                        if(count_s % 3 == 0)
                            sum += count_s / 3 * 2;
                        else
                            sum += count_s / 3 * 2 + 1;
                    }

                }
                else
                {
                    if(count_s > 1)
                    {
                        count_s--;
                        if(count_s % 3 == 0)
                            sum += count_s / 3 * 2 + 1;
                        else
                            sum += count_s / 3 * 2 + 2;
                        
                        count_s = 1;
                        count_d = 1;
                        i++;
                    }
                    else
                    {
                        count_d++;
                    }
                    
                    if(i == s.Length - 1)
                    {
                        sum += count_d;
                    }
                }
            }

            Console.WriteLine(sum);
    
        }
    }