#include <iostream>
#include <cstdio>
#include <string>
#include <vector>

using namespace std;

int main() {
    freopen("strings.in", "r", stdin);
    freopen("strings.out", "w", stdout);

    string s;
    cin >> s;
    int n = s.length();
    vector<vector<int> > v(26);
    int mx = 0;
    for (int i = 0; i < n; i++) v[s[i] - 'a'].push_back(i);
    for (int i = 0; i < 26; i++) mx = max(mx, (int)v[i].size());
    int ans = 1;
    for (int i = 0; i < 26; i++) if (mx == (int)v[i].size()) {
        for (int res = 0; v[i].back() + res < n; res++) {
            bool ok = true;
            for (int j = 0; j < (int)v[i].size(); j++) {
                ok &= s[v[i][j] + res] == s[v[i][0] + res];
            }
            if (!ok) break;
            ans = max(ans, res + 1);
        }
    }
    cout << ans << endl;
    return 0;
}