#include <bits/stdc++.h>

using namespace std;

string s;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	
	cin >> s;
	
	int n = s.size(), n0 = 0, n1 = 0, k0 = 0, k1 = 0, m = n;
	

	
	for(int i = 0; i < n; i++)
	{
		if(s[i] == '1') n1++;
		if(s[i] == '0') n0++;
	}
	
	if(n0 + n1 == n)
	{
		for(int i = 0; i < n; i++)
		{
			m = min(m, min(k0 + n1 - k1, k1 + n0 - k0));
			
			if(s[i] == '0') k0++;
			else k1++;
		}
		
		m = min(m, min(k0 + n1 - k1, k1 + n0 - k0)); 
		
		cout << m;
	}
	else
		cout << "1";
	
	return 0;
}