#include <bits/stdc++.h>
using namespace std;
const int fx[] = {+1, -1, +0, +0};
const int fy[] = {+0, +0, +1, -1};
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
long long int binpow(long long int a, long long int b) {
  long long int res = 1;
  while (b > 0) {
    if (b & 1) res = res * a;
    a = a * a;
    b >>= 1;
  }
  return res;
}
string s;
long long int n;
map<char, long long int> mps;
bool good(long long int x) {
  for (auto cur : mps) {
    long long int cnt = 0;
    char c = cur.first;
    for (long long int i = 0; i < x; i++) {
      if (s[i] == c) cnt++;
    }
    bool flag = false;
    if (cnt) flag = true;
    for (long long int i = x; i < n; i++) {
      if (s[i] == c) {
        cnt++;
      }
      if (s[i - x] == c) {
        cnt--;
      }
      if (cnt == 0) flag = false;
    }
    if (flag) return flag;
  }
  return false;
}
int main() {
  long long int t;
  t = 1;
  while (t--) {
    cin >> s;
    n = s.size();
    for (long long int i = 0; i < n; i++) {
      mps[s[i]] = 1;
    }
    long long int l = 0, r = n;
    while (r - l > 1) {
      long long int m = (l + r) >> 1;
      if (good(m)) {
        r = m;
      } else {
        l = m;
      }
    }
    cout << r << endl;
  }
  return 0;
}
