#include <bits/stdc++.h>
using namespace std;
const int mlen=100100;
int dp[mlen];
int suf[mlen];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    string n;
    cin>>n;
    if(n.length()<=6 && false)
    {
        if(n=="1000000") cout<<0<<endl;
        else
        {
            int len=n.length();
        }
    }
    //sve jedinice i nula
    else
    {
        int len=n.length();
        dp[0]=n[0]-'0';
        for(int i=1;i<len;i++) dp[i]=dp[i-1]+(n[i]-'0');
        suf[len-1]=n[len-1]-'0';
        for(int i=len-2;i>=0;i--) suf[i]=suf[i+1]+(n[i]-'0');
        //for(int i=0;i<len;i++) cout<<dp[i]<<" "<<suf[i]<<endl;
        int mx=len;
        for(int i=0;i<len;i++)
        {
            int t1=len,t2=len,t3=len,t4=len;
            if(n[i]=='0')
            {
                t1=(i+1)-dp[i]+suf[i]; //jedinice
                t2=dp[i]+(len-(i+1)-suf[i]);
            }
            else
            {
                t3=(i+1)-dp[i]+suf[i]-1;
                t4=dp[i]+(len-(i+1)-(suf[i]-1));
            }
            int t=min(min(t1,t2),min(t3,t4));
            mx=min(mx,t);
        }
        cout<<mx<<endl;
    }
}