#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
int n;

int main()
{
    string s;
    cin>>s;
    n=s.size();
    pair<int,int> n1=make_pair(0,0),n0=make_pair(0,0);
    for(int i=0;i<n;i++){
        if(s[i]=='0')n0.se++;
        else n1.se++;
    }
    int res=min(n1.se,n0.se);
    for(int i=0;i<n;i++){
        if(s[i]=='0'){n0.se--;n0.fi++;}
        else {n1.se--;n1.fi++;}
        res=min(res,min(n0.se+n1.first,n1.se+n0.first));
    }
    cout << res << endl;
    return 0;
}