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

int a[MAXN];
int pref1[MAXN];
int pref0[MAXN];

int main()
{
    string s;
    cin >> s;
    int br0 = 0, br1 = 0;
    int n = s.size();
    for(int i = 0; i < n; i++)
    {
        a[i] = s[i] - '0';
        if(a[i] == 0)
        {
            br0++;
        }
        else
        {
            br1++;
        }
    }
    if(a[0] == 0)
    {
        pref0[0] = 1;
    }
    else
    {
        pref1[1] = 1;
    }
    for(int i = 0; i < n; i++)
    {
        if(a[i] == 0)
        {
            pref0[i] = pref0[i - 1] + 1;
            pref1[i] = pref1[i - 1];
        }
        else
        {
            pref1[i] = pref1[i - 1] + 1;
            pref0[i] = pref0[i - 1];
        }
    }
    int res = min(br1, br0);
    for(int i = 0; i < n; i++)
    {
        res = min(res, pref1[i] + br0 - pref0[i]);
    }
    for(int i = 0; i < n; i++)
    {
        res = min(res, pref0[i] + br1 - pref1[i]);
    }

    cout << res << endl;
    return 0;
}