#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int calculateValue(const string &s) {
int maxValue = 1;
int currentValue = 1;
for (size_t i = 1; i < s.size(); ++i) {
if (s[i] != s[i - 1]) {
currentValue++;
} else {
maxValue = max(maxValue, currentValue);
currentValue = 1;
}
}
maxValue = max(maxValue, currentValue);
return maxValue;
}
void ddd(string &s, vector<int> &U) {
sort(U.rbegin(), U.rend());
for (int x : U) {
if (x > 0) {
for (int i = 0; i < x; ++i) {
s[i] = (s[i] == '0') ? '1' : '0';
}
for (int i = x; i < s.size(); ++i) {
s[i] = (s[i] == '0') ? '1' : '0';
}
} else if (x == 0) {
for (char &c : s) {
c = (c == '0') ? '1' : '0';
}
}
}
}
int main() {
string s;
cin >> s;
int n = s.length();
vector<int> U;
if (n > 0) U.push_back(n);
ddd(s, U);
int value = calculateValue(s);
cout << value << endl;
return 0;
}