#include <bits/stdc++.h>
using namespace std;
string s;
int n;
bool vis[26];
int sum[1000005][26];
bool chk(int len) {
  for (int i = 0; i < 26; i++) vis[i] = 1;
  for (int i = 1; i <= n - len + 1; i++) {
    for (int j = 0; j < 26; j++) {
      if (vis[j] == 0) continue;
      if (sum[i + len - 1][j] - sum[i - 1][j] == 0) vis[j] = 0;
    }
  }
  for (int i = 0; i < 26; i++)
    if (vis[i]) return 1;
  return 0;
}
int main() {
  cin >> s;
  n = s.length();
  s = '#' + s;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 26; j++) sum[i][j] = sum[i - 1][j];
    sum[i][s[i] - 'a']++;
  }
  int l = 0, r = n;
  int mid;
  while (r - l > 4) {
    mid = (l + r) / 2;
    if (chk(mid))
      r = mid;
    else
      l = mid;
  }
  for (l; l <= r; l++) {
    if (chk(l)) {
      cout << l;
      return 0;
    }
  }
  return 0;
}
