import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

void main() {
    string s;
    scan(s);

    int n = s.length.to!int;
    auto x = new int[](n);
    iota(n).each!(i => x[i] = s[i] - '0');

    bool check(int k) {
        if (n - k + 1 >= k) {
            return 1;
        }

        auto y = x.dup;
        auto w = new int[](n + 1);
        int c = 0;

        foreach (i ; 0 .. n - k + 1) {
            c ^= w[i];

            if (y[i] == (c^1)) {
                y[i] = 0;
                w[i + k] = 1;
                c ^= 1;
            }
        }

        foreach (i ; n - k + 1 .. n) {
            c ^= w[i];
            y[i] ^= c;
        }

        debug {
            writefln("%d:%(%b%)", k, w);
            writefln("%d:%(%b%)", k, y);
        }

        return y.take(k).all!"a == 0";
    }

    int top = n + 1, btm = 1;

    while (top - btm > 1) {
        int mid = (top + btm) / 2;
        (check(mid) ? btm : top) = mid;
    }

    writeln(btm);
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}