#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	ll r=s.size()+1, x, y;
	vector<ll> b1(s.size());
	vector<ll> b0(s.size());
	if(s[0]=='1')
    {
        b1[0]=1;
    }
    else
    {
        b0[0]=1;
    }
	for(ll i=1; i<s.size(); i++)
    {
        b1[i]=b1[i-1];
        b0[i]=b0[i-1];
        if(s[i]=='1')
        {
            b1[i]++;
        }
        else
        {
            b0[i]++;
        }
    }
    for(ll i=0; i<s.size(); i++)
    {
        x=b1[i]+b0[s.size()-1]-b0[i];
        y=b0[i]+b1[s.size()-1]-b1[i];
        r=min(min(x,y),r);
    }
    cout << r << "\n";
}