using System;

namespace Petlja4
{
    class Program
    {
        static void Main()
        {
            string unos;
            int i, j, k, counter = 0;
            unos = Console.ReadLine();

            int[] levels = new int[unos.Length];

            for (i = 0; i < unos.Length; i++) //set all to 0
            {
                levels[i] = 0;
            }

            for (i=0; i<unos.Length;i++)
            {
                for(j = (i+1); j < (unos.Length); j++)
                {
                    if (j >= i + 1)
                    {
                        if (levels[i] == levels[j] && unos[i] == unos[j])
                        {
                            if (((j - i) % 2) != 0)
                            {
                                for (k = (j - 1); k < (unos.Length); k++)
                                {
                                    levels[k]++;
                                }
                                counter++;
                                break;
                            }

                            if (j == (i + 1))
                            {
                                for (k = (j - 1); k < (unos.Length); k++)
                                {
                                    levels[k]++;
                                }
                                counter++;
                                break;
                            }
                        }
                    }  
                }

                if (i < (unos.Length - 1))
                {
                    if (levels[i] == (levels[i + 1] - 1) && unos[i] == unos[i + 1])
                    {
                        counter++;
                    }
                }
            }

            Console.WriteLine(counter);
        }
    }
}