#include <bits/stdc++.h>
using namespace std;

#define endl "\n"
#define ll long long
#define PB push_back
#define F first
#define S second
#define all(a) a.begin(), a.end()
#define MAX 100005
#define Fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define w(a) cout<<#a<<" : "<<a<<endl;

bool bilo[10];
int N;
int a[MAX],b[MAX];
//int ukupno;
string x;
int ans=0;

void obradi()
{
    int br=0;
    for(int i=0; i<N; ++i) if(a[i]!=b[i]) br++;
    ans=min(ans,br);
}
void varijacije(int pos)
{
    if(pos==N) return obradi();
    for(int i=0; i<10; ++i)
    {
        if(bilo[i]) continue;
        bilo[i]=1;
        a[pos]=i;
        varijacije(pos+1);
        bilo[i]=0;
    }
    if(pos>0)
    {
        a[pos]=a[pos-1];
        varijacije(pos+1);
    }
}

void Prvi()
{
    ans=N;
    for(int i=0; i<N; ++i) b[i]=x[i]-'0';
    for(int i=0; i<10; ++i) bilo[i]=1;
    for(int i=0; i<N; ++i) bilo[b[i]]=0;
    varijacije(0);
    cout<<ans;
}
void Drugi()
{
    int nul[N+1], jed[N+1];
    for(int i=0; i<=N; ++i) nul[i]=jed[i]=0;
    for(int i=1; i<=N; ++i)
    {
        nul[i]=nul[i-1]+(x[i-1]=='0');
        jed[i]=jed[i-1]+(x[i-1]=='1');
    }
    int ans=N;
    for(int i=0; i<=N; ++i)
    {
        int ans1=jed[i]+nul[N]-nul[i];
        int ans2=nul[i]+jed[N]-jed[i];
        ans=min(ans,min(ans1,ans2));
    }
    cout<<ans;
}

int main()
{
    Fast;
    cin>>x;
    //x="1000000";
    N=x.size();
    bool ind=true;
    for(auto c:x)
    {
        if(c!='1' && c!='0')
        {
            ind=false;
            break;
        }
    }
    if(ind) Drugi();
    else Prvi();
    return 0;
}