program fair;

const
	maxn = 200001;

var
	v, a, b: array [0..maxn + 1] of longint;
	i, n, ans: longint;
	s: string;

begin
	reset(input, 'fair.in');
	rewrite(output, 'fair.out');

	readln(s);
	n := length(s);

	for i := 1 to n do begin
		v[i] := ord(s[i]) - ord('0');
	end;

	a[0] := 0;
	for i := 1 to n do begin
		if i mod 2 = 1 then
			a[i] := a[i - 1] + v[i]
		else
			a[i] := a[i - 1] - v[i];
	end;

	b[n + 1] := 0;
	for i := n downto 1 do begin
		if i mod 2 = 1 then
			b[i] := b[i + 1] + v[i]
		else
			b[i] := b[i + 1] - v[i];
	end;

	ans := -1;

	for i := 0 to n - 1 do begin
		if a[i] = b[i + 2] then begin
			ans := i + 1;
			break;
		end;
	end;

	writeln(ans);

	close(input);
	close(output);
end.