include <iostream>
#include <vector>
#include <string>
#include <stack>

using namespace std;

int main() {
    string S;
    cin >> S;
    for (int K = S.size(); K > 0; --K) {
        stack <vector <string> > st;
        vector <string> init;
        init.push_back(S);
        st.push(init);
        while (!st.empty()) {
            vector <string> v = st.top();
            st.pop();
            if (v.size() == K) {
                if (v[v.size() - 2] != v[v.size() - 1]) {
                    cout << K << endl;
                    return 0;
                }
            } else {
                string s = v.back();
                v.pop_back();
                for (int i = 1; i <= 2; ++i) {
                    string check = s.substr(0, i);
                    if (v.empty() || check != v.back()) {
                        v.push_back(s.substr(0, i));
                        v.push_back(s.substr(i));
                        st.push(v);
                        v.pop_back();
                        v.pop_back();
                        break;
                    }
                }
            }
        }
    }
    return 0;
}
