using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Debug = System.Diagnostics.Debug;
using static System.Math;
using System.Runtime.CompilerServices;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

static class P
{
    static void Main()
    {
        string s = Console.ReadLine();
        List<int> chunks = new List<int>();
        var count = 1;
        var last = s[0];
        for (int i = 1; i < s.Length; i++)
        {
            if (last != s[i])
            {
                chunks.Add(count);
                count = 0;
                last = s[i];
            }
            count++;
        }
        chunks.Add(count);
        var res = chunks.Sum(x => (x / 3) * 2 + (x % 3 != 0 ? 1 : 0));
        bool flag = false;
        for (int i = 0; i < chunks.Count; i++)
        {
            if (chunks[i] == 1) flag = false;
            else if (chunks[i] % 3 == 2)
            {
                if (flag)
                {
                    res++;
                    flag = false;
                }
                else
                {
                    flag = true;
                }
            }
        }
        Console.WriteLine(res);
    }
}