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;
            string a = Console.ReadLine();
            for(int i=0;i<a.Length;i++)
            {
                if (a[i] == '0')
                    br1++;
                else if (a[i] == '1')
                    br2++;
            }
            Console.WriteLine(Math.Min(br1,br2-1));
        }
    }
    
}