#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
char s[N];
int sum[26], sum2[26];
int main() {
  cin >> s;
  int n = strlen(s);
  int l = 1, r = n;
  while (l <= r) {
    int mid = l + r >> 1;
    memset(sum, 0, sizeof sum);
    memset(sum2, 0, sizeof sum2);
    for (int i = 0; i < mid - 1; i++) sum[s[i] - 'a']++;
    for (int i = mid - 1; i < n; i++) {
      sum[s[i] - 'a']++;
      for (int i = 0; i < 26; i++) sum2[i] += (sum[i] > 0);
      sum[s[i - mid + 1] - 'a']--;
    }
    int tot = 0;
    for (int i = 0; i < 26; i++) tot += (sum2[i] == n - mid + 1);
    if (tot)
      r = mid - 1;
    else
      l = mid + 1;
  }
  cout << r + 1 << endl;
  return 0;
}
