#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mk make_pair
#define v_sort(x) sort(x.begin(),x.end())
#define v_gsort(x) sort(x.begin(),x.end(),greater<int>())
#define v_find(x,num) find(x.begin(),x.end(),num)
#define PI 3.14159265
#define MOD 998244353
#define MOD1 1000000007

using namespace std;

void Solve(){
  string s;
  cin>>s;
  int suf0=0;
  int suf1=0;
  for(int i=0;i<s.size();i++){
    suf0+=s[i]=='0';
    suf1+=s[i]=='1';
  }
  int ans=min(suf0,suf1);
  int pref0 = 0, pref1 = 0;
  for(auto &it:s)
  {
    pref0 += (it == '0'), suf0 -= (it == '0');
    pref1 += (it == '1'), suf1 -= (it == '1');
    ans = min(ans, pref1 + suf0);
    ans = min(ans, pref0 + suf1);
  }
  cout << ans << endl;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int t=1;
//  cin>>t;
  while(t--){
    Solve();
  }
  return 0;
}