using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.SymbolStore;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Net.WebSockets;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Schema;

namespace ConsoleApplication2
{

    class Program
    {
        static void Main(string[] args)
        {
            int br1 = 0, br2 = 0, br = 0, suma = 0, brc = 0, bru = 0, brnula = 0, brjed = 1 ;
            string a = Console.ReadLine();
            char[] c = a.Distinct().ToArray();
            Array.Sort(c);
            if (c[0] == '0')
                br = c.Length;
            else br = c.Length + 1;
            for ( int i = 0; i < a.Length; i++)
            {
                if (a[i] == '0')
                    br1++;
                else if (a[i] == '1')
                    br2++;
                if (i > 0)
                {
                    if (a[i] == a[i - 1])
                    {
                        if((a[i] != '0'))
                        {
                            bru++;
                        }
                        else if (a[i] == '0')
                            brnula++;

                        if (a[i] == '1')
                            brjed++;
                    }
                }
                   
                suma += (int)(a[i]-48);
            }
            if(br1+br2==a.Length)
            {
                if(br2==br1 && brjed+1==br2 && brnula+1==br1)
                    Console.WriteLine(br2/2);
                else if (br2==br1 && brjed == 1 && brnula + 1 == 1)
                    Console.WriteLine(br2/2);
                else if(br2-1>0 && br2>br1)
                    Console.WriteLine(Math.Min(br1, br2-brjed));
                else if(br2 - 1 > 0 && br2 < br1)
                    Console.WriteLine(Math.Min(br1, br2  - brjed));
                else if (br2==0)
                    Console.WriteLine(br2);
                else Console.WriteLine(br2-brjed);
            }
            else
            {
                if(br1==0)
                {
                    if (bru == 0)
                        brc = Math.Abs(suma / (br) - br + 1);
                    else
                        brc = Math.Abs(suma / (br) - br +1)-(bru+1)/2 ;
                }
                else if(br1!=0)
                {
                    
                    if (bru == 0)
                    {
                        if (brnula == 0)
                            br1 = 1;
                        brc = Math.Abs(suma / (br) - br + 1) + br1 - brnula - 1;

                    }
                    else if (bru > 0)
                    {
                        if (brnula == 0)
                            br1 = 0;
                        brc = Math.Abs(suma / (br) - br) + br1 - brnula;
                    }

                }
                Console.WriteLine(brc);
            }
        }
    }
    
}