using System;
using System.Collections.Generic;
class Program
    {
        static void Main(string[] args)
    	{
            string s = Console.ReadLine();
            char c = '0';
            int count = 0;
            int ans = 0;
            for (int i=0; i<s.Length; i++)
            {
                if (c != s[i])
                {
                    if (count % 3 == 2)
                    {
                        ans += 2 * (count + 1) / 3;
                        i++;
                        c = s[i];
                        count = 1;
                    }
                    else
                    {
                        ans += 2 * count / 3 + count % 3;
                        c = s[i];
                        count = 1;
                    }
                    
                }
                else count ++;
            }
            if (count % 3 == 2) ans += 2 * (count + 1) / 3 - 1;
            else ans += 2 * count / 3 + count % 3;
            Console.WriteLine(ans);
        }
    
    }
    //mcs Main.cs
    //mono Main.exe