#include <iostream>
#include <unordered_map>
#include <string>
#include <utility>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int najveci = 0;
    string s;
    getline(cin, s);
    int duz = s.length();
    unordered_map<char, vector<int>> mapa;
    for (int i = 0; i < duz; i++)
        mapa[s[i]].push_back(i);
    vector<int> obradili(26);
    for (char x : s) {
        if (obradili[x - 'a'])
            continue;
        obradili[x - 'a']++;
        vector<pair<int, int>> intervali;
        int poc = 0, kraj = -1, trenut = 0;
        auto niz = mapa[x];
        int broj_p = niz.size();
        for (int i = 0; i < broj_p - 1; i++) {
            if (niz[i + 1] - niz[i] % 2 == 0)
                continue;
            poc = kraj + 1;
            kraj = niz[i] + (niz[i + 1] - niz[i]) / 2;
            if (kraj - poc >= 1)
                intervali.push_back(make_pair(poc, kraj));
        }
        poc = kraj + 1;
        if (duz - 1 - poc >= 1) {
            intervali.push_back(make_pair(poc, duz - 1));
        }
        int br_inter = intervali.size();
        for (int i = 0; i < br_inter - 1; i++) {
            int x1 = get<0>(intervali[i]), y1 = get<1>(intervali[i]);
            int x2 = get<0>(intervali[i + 1]), y2 = get<1>(intervali[i + 1]);
            int raz = min(y1 - x1, y2 - x2) + 1;
            int x = 1;
            for (int j = 0; j < raz; j++) {
                if (s[x2 + j] == s[x2 + j - x])
                    trenut++;
                x += 2;
            }
        }
        najveci = max(najveci, trenut);
    }

    cout << najveci << endl;
}