using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var firstSize = s.Length;
            var size = 0;
            var count = 0;
            while (true)
            {
                size = s.Length;
                s = s.Replace("01", "");
                s = s.Replace("10", "");
                if (size == s.Length)
                    count++;
                else
                    count = 0;

                // 2連続で変わらない場合、対象が無くなったと確定する
                if (count == 2) break;
            }

            Console.WriteLine(firstSize - s.Length);
        }
    }
}