import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;

public class fair_dg {

	public static void main(String[] args) {
		new Thread(){
			public void run() {
				try {
					new fair_dg().run();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}.start();
	}
	
	final int maxN = 2000001;

	protected void run() throws IOException {
		BufferedReader in = new BufferedReader(new FileReader("fair.in"));
		PrintWriter out = new PrintWriter("fair.out");
		
		char[] c = in.readLine().toCharArray();
		int n = c.length;
		assert n >= 1 && n <= maxN && (n % 2 == 1) : "Wrong n";
		
		int all = 0;
		for (int i = 0; i < n; i++) {
			assert c[i] == '0' || c[i] == '1' : "Symbol " + (i + 1) + " is wrong";
			if (c[i] == '1') {
				all++;
			}
		}
		
		int[] cr = new int[n];
		int[] cl = new int[n];
		for (int i = 0; i < n - 1; i++) {
			cl[i + 1] = cl[i];
			if (i % 2 == 0 && c[i] == '1') {
				cl[i + 1]++;
			}
		}
		
		for (int i = n - 1; i > 0; i--) {
			cr[i - 1] = cr[i];
			if (i % 2 == 1 && c[i] == '1') {
				cr[i - 1]++;
			}
		}
		
		int res = 0;
		for (int i = 0; i < n; i++) {
			int cnt = all;
			if (c[i] == '1') {
				cnt--;
			}
			if ((cl[i] + cr[i]) * 2 == cnt) {
				res = i + 1;
			}
		}
		
		out.println(res);
		
		assert in.readLine() == null : "Extra information";
		
		in.close();
		out.close();
	}

}
