import std.stdio, std.algorithm, std.conv, std.array, std.string;

void main()
{
    auto S = readln.chomp.to!(dchar[]);
    auto N = S.length;
    size_t i = 0, j = S.length - 1;
    auto a = S[0], b = S[0], c = S[$-1], d = S[$-1];

    int x, y;
    foreach (s; S) {
        ++(s == '1' ? x : y);
    }
    if (!x || !y) {
        writeln(N);
        return;
    }

    while (i < j) {
        if (i + 1 < N - j) {
            while (a == b) b = S[++i];
            a = S[i];
        } else {
            while (c == d) c = S[--j];
            d = S[j];
        }
    }
    if (i == j) i += 1;
    writeln(i > N - j - 1 ? i : N - j - 1);
}