using System.Linq;
using System.Text;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Numerics;

namespace AtCoder
{
    class Program
    {

        const int BiggestMod = 1000000007;

        public static void Main()
        {

            int numZero = 0, numOne = 0, numSelectable = 0;
            var buf = Console.ReadLine();

            foreach (var chr in buf)
                if (chr == '0') numZero++;
                else if (chr == '1') numOne++;
                else if (chr == '?') numSelectable++;

            var unBalance = Math.Abs(numZero - numOne);

            if (unBalance > numSelectable) Console.WriteLine((unBalance - numSelectable));
            else Console.WriteLine((numSelectable - unBalance) % 2);
            
        }

    }

}
