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

using namespace std;
using namespace boost;

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

    vector<pair<pair<pair<int64_t, int64_t>, pair<int64_t, int64_t>>, int64_t>>
            d;
    vector<pair<pair<pair<int64_t, int64_t>, pair<int64_t, int64_t>>, int64_t>>
            d2;
    d.emplace_back(make_pair(make_pair(0L, 0L), make_pair(0L, 0L)), 1L);
    for (auto idx : irange(0uL, s.size())) {
        auto c = s[idx];
        for (const auto& dd : d) {
            if (dd.first.second.second < 2) {
                d2.emplace_back(dd);
                ++d2.back().first.second.second;
            }

            if (dd.first.first.second == dd.first.second.second) {
                bool is_same = true;
                for (auto i : irange(0L, dd.first.first.second)) {
                    if (s[dd.first.first.first + i] !=
                        s[dd.first.second.first + i]) {
                        is_same = false;
                        break;
                    }
                }

                if (is_same) {
                    continue;
                }
            }

            d2.emplace_back(make_pair(dd.first.second, make_pair(idx, 1)),
                            dd.second + 1);
        }

        d.swap(d2);
        d2.clear();
    }

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

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