import java.io.*;
import java.util.*;

public class fair_md implements Runnable {
	private BufferedReader in;
	private PrintWriter out;

	public void run() {
		try {
			solve();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	private void solve() throws IOException {
		Locale.setDefault(Locale.US);
		in = new BufferedReader(new FileReader("fair.in"));
		out = new PrintWriter("fair.out");
		String s = in.readLine();
		int[] a = new int[2];
		int[] b = new int[2];
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == '1')
				b[i % 2]++;
		}
		int ans = 0;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == '1')
				b[i % 2]--;
			if (a[0] + b[1] == a[1] + b[0]) {
				ans = i + 1;
				break;
			}
			if (s.charAt(i) == '1')
				a[i % 2]++;
		}
		out.println(ans);
		in.close();
		out.close();
	}

	public static void main(String[] args) {
		new Thread(new fair_md()).start();
	}
}
