#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
int cnt[27], flag[27], l;
char s[100015];
bool check(int k) {
  memset(cnt, 0, sizeof(cnt)), memset(flag, -1, sizeof(flag));
  for (int i = 1; i <= k; ++i) cnt[s[i] - 'a']++;
  for (int i = 0; i < 26; ++i)
    if (!cnt[i]) flag[i] = 0;
  for (int i = 2; i + k - 1 <= l; ++i) {
    --cnt[s[i - 1] - 'a'], ++cnt[s[i + k - 1] - 'a'];
    if (!cnt[s[i - 1] - 'a']) flag[s[i - 1] - 'a'] = 0;
  }
  int f = 0;
  for (int i = 0; i < 26; ++i)
    if (flag[i]) f = 1;
  return f;
}
int main() {
  scanf("%s", s + 1);
  l = strlen(s + 1);
  int s = 1, e = l, mi, ans;
  while (s <= e) {
    mi = s + e >> 1;
    if (check(mi))
      e = (ans = mi) - 1;
    else
      s = mi + 1;
  }
  printf("%d\n", ans);
  return 0;
}
