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

void main() {
    auto S = readln.chomp;
    int[] A;

    int tmp = 0;
    char last = '2';

    foreach (s; S) {
        if (s != last && tmp != 0) {
            A ~= tmp;
            tmp = 0;
        }
        tmp += 1;
        last = s;
    }

    if (tmp > 0) {
        A ~= tmp;
    }

    int ans = 0;
    
    foreach (i; 0..A.length.to!int-1) {
        ans = max(ans, A[i] + A[i+1]);
    }

    ans = min(ans, max(S.count('0'), S.count('1')));
    ans.writeln;
}
