#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0)
#define mp make_pair
#define xx first
#define yy second
#define dif(x) ((x).yy-(x).xx)
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(x) (x).begin(),(x).end()
#define ub(a,x) upper_bound(all(a),x)
#define lb(a,x) lower_bound(all(a),x)
#define inv(n) power((n), mod - 2)
#define ff(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
#define fff(i,a,b) for (int (i) = (a); (i) <= b; (i)++)
#define bff(i,a,b) for (int (i) = (b)-1; (i) >= (a); (i)--)
#define bfff(i,a,b) for (int (i) = (b); (i) >= (a); (i)--)
#define sum_overflow(a,b) __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0)
#define mul_overflow(a,b) __builtin_mul_overflow_p (a, b, (__typeof__ ((a) + (b))) 0)

using namespace std;
long double typedef ld;
unsigned int typedef ui;
long long int typedef li;
pair<int,int> typedef pii;
pair<li,li> typedef pli;
vector<vector<int>> typedef graph;
unsigned long long int typedef ull;
const ld PI = 3.14159265359;
//const int mod = 998244353;
const int mod = 1000000007;
const li inf = 9223372036854775807ll;

using namespace __gnu_pbds;
template <class T> using oset = tree<T, null_type,greater<T>, rb_tree_tag,tree_order_statistics_node_update>;
template <class T> using omset = tree<T, null_type,less_equal<T>, rb_tree_tag,tree_order_statistics_node_update>;







//Note to self: Check for overflow

int dp1[10][1024];
int dp2[10][1024];
int dp3[10][1024];

int main()
{
    FAST;

    string s; cin>>s;
    int n=s.size(),res;
    ff(i,0,n) if (s[i]>'1') goto radinormalno;

    int pre0[100003],pre1[100003];
    int suf0[100003],suf1[100003];
    pre0[0]=(s[0]=='0');
    pre1[0]=(s[0]=='1');
    suf0[n-1]=(s[n-1]=='0');
    suf1[n-1]=(s[n-1]=='1');

    ff(i,1,n)
    {
        pre0[i]=pre0[i-1];
        pre1[i]=pre1[i-1];
        if (s[i]=='0') pre0[i]++;
        else pre1[i]++;
    }
    bff(i,0,n-1)
    {
        suf0[i]=suf0[i+1];
        suf1[i]=suf1[i+1];
        if (s[i]=='0') suf0[i]++;
        else suf1[i]++;
    }

    //ff(i,0,n) cout<<pre0[i]<<" "; cout<<endl;
    //ff(i,0,n) cout<<pre1[i]<<" "; cout<<endl;
    //ff(i,0,n) cout<<suf0[i]<<" "; cout<<endl;
    //ff(i,0,n) cout<<suf1[i]<<" "; cout<<endl;

    res=min(suf0[0],suf1[0]);
    ff(i,1,n) res=min(res,min(pre0[i-1]+suf1[i],pre1[i-1]+suf0[i]));

    return cout<<res,0;

    radinormalno:

    ff(j,0,10) ff(k,0,1024) dp1[j][k]=mod;
    ff(j,0,10) dp1[j][1<<j]=(s[0]-'0'!=j);

    /*ff(j,0,3)
    {
        ff(k,0,8) cout<<dp1[j][k]<<" ";
        cout<<endl;
    } cout<<endl;*/

    ff(i,1,n)
    {

        ff(j,0,10) ff(k,0,1024) dp2[j][k]=mod;
        ff(j,0,10) ff(k,0,1024) dp3[j][k]=mod;
        ff(k,0,1024)
        {
            int onomoje=mod;
            ff(j,0,10) if (dp1[j][k]<onomoje) onomoje=dp1[j][k];

            int kk=k,st=1;
            ff(j,0,10)
            {
                if (kk&1) dp2[j][k]=dp1[j][k]+(s[i]-'0'!=j);
                else dp3[j][k|st]=min(dp3[j][k|st],onomoje+(s[i]-'0'!=j));
                kk>>=1; st<<=1;
            }
        }
        ff(j,0,10) ff(k,0,1024) dp1[j][k]=min(dp2[j][k],dp3[j][k]);

        /*ff(j,0,3)
        {
            ff(k,0,8) cout<<dp1[j][k]<<" ";
            cout<<endl;
        } cout<<endl;*/
    }

    int nini=mod;
    ff(j,0,10) ff(k,0,1024) nini=min(nini,dp1[j][k]);
    cout<<nini<<endl;
}

//Note to self: Check for overflow