#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>

using namespace std;

int main()
{
    string naslov;
    cin >> naslov;

    vector<int> slova[26];
    int bend[naslov.length()] = {};
    stack<int> bends;

    for(int i = naslov.length() - 1; i >= 0; i--){
        int slovo = ((int)naslov[i]) - 97;
        slova[slovo].push_back(i);
        bool added = false;
        for(int y = 0; y < slova[slovo].size() - 1; y++) if(slova[slovo].at(y) % 2 != slova[slovo].at(slova[slovo].size() - 1) % 2) {
            bend[(slova[slovo].at(y) + slova[slovo].at(slova[slovo].size() - 1)) / 2]++;
            bends.push((slova[slovo].at(y) + slova[slovo].at(slova[slovo].size() - 1)) / 2);
            added = true;
        }
        if(added) bends.push(-1);
    }

    int res[naslov.length()] = {};

    while(!bends.empty()){
        bends.pop();
        vector<int> nodes;
        while(!bends.empty() && bends.top() != -1) {
            nodes.push_back(bends.top());
            bends.pop();
        }
        for(int node : nodes) {
            for(int i = 0; i < node-1; i++) if(res[i] != 0 && find(nodes.begin(), nodes.end(), i) == nodes.end()) res[i]++;
            res[node]++;
        }
    }

    int result = 0;
    for(int i = 0; i < naslov.length(); i++) result = max(result, res[i]);
    cout << result;
}