#include <bits/stdc++.h>
using namespace std;
const int inf = 2e9;
const long long INF = 4e17;
const int mod = 1e9 + 7;
const double eps = 1e-9;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  int len = s.length();
  int lo = 1, hi = len, ans;
  while (lo <= hi) {
    int mid = (lo + hi) >> 1;
    int cnt[26];
    bool mark[26];
    for (int i = 0; i < 26; i++) mark[i] = true, cnt[i] = 0;
    for (int i = 0; i < mid; i++) cnt[s[i] - 'a']++;
    for (int i = 0; i < 26; i++)
      if (!cnt[i]) mark[i] = false;
    for (int i = 1; i + mid - 1 < len; i++) {
      cnt[s[i - 1] - 'a']--;
      cnt[s[i + mid - 1] - 'a']++;
      for (int j = 0; j < 26; j++)
        if (!cnt[j]) mark[j] = false;
    }
    bool ok = false;
    for (int i = 0; i < 26; i++)
      if (mark[i]) ok = true;
    if (ok)
      ans = mid, hi = mid - 1;
    else
      lo = mid + 1;
  }
  cout << ans;
  return 0;
}
