#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
    string s;
    cin >> s;

    vector<pair<pair<string, string>, int64_t>> d;
    d.emplace_back(make_pair("", ""), 1);
    for (auto c : s) {
        vector<pair<pair<string, string>, int64_t>> d2;
        for (const auto& dd : d) {
            if (dd.first.second.size() < 2) {
                d2.emplace_back(make_pair(dd.first.first, dd.first.second + c),
                                dd.second);
            }

            if (dd.first.first != dd.first.second) {
                d2.emplace_back(make_pair(dd.first.second, string(1, c)),
                                dd.second + 1);
            }
        }

        d.swap(d2);
    }

    int64_t m = -1;
    for (const auto& dd : d) {
        if (dd.first.first == dd.first.second && dd.first.second.size() == 1) {
            continue;
        }
        m = max(m, dd.second);
    }

    std::cout << m << endl;
}