using System;
using System.Collections.Generic;

namespace atcorder
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            atcorder.Test.Run();
        }
    }




    public class Test
    {
        public static void Run()
        {
            string S = Console.ReadLine();
            int count = 0;
            for (int i = 0; i < S.Length; i++)
            {
                if (i == S.Length - 1)
                {
                    Console.WriteLine(count);
                    return;
                }
                if (S[i] != S[i + 1])
                {
                    S = S.Remove(i, 2);
                    count += 2;
                    i -= 2;
                    if (i == -2) i = -1;
                    continue;
                }

            }
        }
    }







    public class Input
    {
        int arg;
        int length;
        string s;
        string[] ss;
        char sep;
        public Input(char _sep = '\0')
        {
            sep = _sep;
        }
        public void ReadLine()
        {
            s = Console.ReadLine();
            if (sep != '\0') ss = s.Split(sep);
            else
            {
                ss = new string[1];
                ss[0] = s;
            }
            arg = 0;
            length = ss.Length;
        }
        public T Next<T>()
        {
            if (arg == length) throw new IndexOutOfRangeException();
            return (T)Convert.ChangeType(ss[arg++], typeof(T));
        }
        public void SetSeparater(char _sep)
        {
            sep = _sep;
        }
    }
}