#include <bits/stdc++.h>
using namespace std;

long long int N, a[26], m[26], i, c;
char s[114];

int main(){
    scanf("%s", s);
    N = strlen(s);
    fill(a, a + 26, -1);
    for(int i = 0; i < N; ++i){
        c = s[i] - 97;
        m[c] = max(m[c], i - a[c] - 1);
        a[c] = i;
    }
    for(int i = 0; i < 26; ++i){
        m[i] = max(m[i], N - a[i] - 1);
    }
    cout << *min_element(m, m + 26) << endl;
    return 0;
}
