#include <bits/stdc++.h>   using namespace std;   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int t;     string s;     cin >> s;     long long int n = s.length();     long long int dp[s.length() + 5][27];     for (int i = 0; i <= s.length(); i++) {       for (int j = 0; j < 27; j++) dp[i][j] = 0;     }     for (int i = 0; i < s.length(); i++) {       if (i != 0) {         for (int j = 0; j < 27; j++) {           dp[i + 1][j] = dp[i][j];         }       }       dp[i + 1][s[i] -  a ]++;     }     long long int ans = 1000000000000000000;     for (char c =  a ; c <=  z ; c++) {       long long int low = 1, high = n;       long long int mid;       while (low <= high) {         mid = (low + high) / 2;         bool f = 1;         for (int i = mid; i <= n; i++) {           if (dp[i][c -  a ] - dp[i - mid][c -  a ] <= 0) {             f = 0;           }         }         if (f) {           high = mid - 1;         } else {           low = mid + 1;         }       }       ans = min(low, ans);     }     cout << ans << endl;   }   