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

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

    int n = s.length.to!int;

    int btm = 1, top = n + 1;

    bool check(int k) {
        if (2*k <= n) {
            return true;
        }

        bool b = 1;
        char ch = s[n-k];

        foreach (i ; n-k .. k) {
            b &= s[i] == ch;
        }

        return b;
    }

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

        if (check(mid)) {
            btm = mid;
        }
        else {
            top = mid;
        }
    }

    writeln(btm);
}




void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    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);
        }
    }
}
