#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 50004;
char s[N];
int dp[N][103];
int pre[N][26];
int main() {
    int i, j;
    scanf("%s", s+1);
    int n = strlen(s+1);
    for(i = 1; i <= n; i++) {
        for(j = 0; j < 26; j++)
            pre[i][j] = pre[i-1][j];
        pre[i][s[i]-'A'] = i;
    }
    dp[0][0] = n;
    for(i = 0; i < n; i++) {
        for(j = 0; j <= 100; j++) {
            int st = dp[i][j];
            printf("st=%d\n",st);
            while(st = pre[st][s[i+1]-'A']) {
                dp[i+1][j+1] = min(dp[i+1][j+1], st);
            }
        }
    }
    int ans = 0;
    for(i = 0; i <= 100; i++)
        ans = max(ans, dp[n][i]);
    printf("%d\n", ans);
    return 0;
}