using System;
using System.Collections;
using System.Collections.Generic;
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;

        bool isRemove = true;
        while (isRemove)
        {
            isRemove = false;
            for (int i = 0; i < originlist.Count - 1; i += 2)
            {
                if (originlist[i] != originlist[i + 1])
                {
                    originlist.RemoveAt(i + 1);
                    originlist.RemoveAt(i);
                    i -= 2;
                }
            }
        }
        Console.WriteLine(originCount - originlist.Count);
    }
}