using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
class Unification
{
    static void Main(string[] args)
    {
        string input = Console.ReadLine();
        var originlist = new List<int>();
        for (int i = 0; i < input.Length; i++)
        {
            originlist.Add(int.Parse(input[i].ToString()));
        }

        var originCount = originlist.Count;

        int beforeCount = -1;
        while (beforeCount != originlist.Count)
        {
            beforeCount = originlist.Count;
            var chunks = originlist.Select((v, i) => new { v, i }).GroupBy(x => x.i / 2).Select(g => g.Select(x => x.v)).ToArray();
            for (int i = chunks.Length; i < 0; i--)
            {
                var map = chunks[i].ToArray();
                if (map[0] != map[1])
                {
                    originlist.RemoveRange(i * 2, 2);
                }
            }
        }
        Console.WriteLine(originCount - originlist.Count);

    }
}