using System;
using System.Collections.Generic;

namespace C___Unification
{
    class Program
    {
        static void Main (string[] args)
        {
            var s = Console.ReadLine ();
            var a = new List<char> ();
            for (var i = 0; i < s.Length; i++)
            {
                a.Add (s[i]);
            }
            var ans = 0;
            for (;;)
            {
                var count = 0;
                for (var i = 1; i < a.Count; i++)
                {
                    if (a[i - 1] != a[i])
                    {
                        a.RemoveRange (i - 1, 2);
                        count++;
                        ans += 2;
                    }
                }
                if (count == 0)
                    break;
            }
            Console.WriteLine (ans);
        }
    }
}