#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const long long mod = 1e9 + 7;
const long long INF = 1e18 + 1LL;
const int inf = 1e9 + 1e8;
const double PI = acos(-1.0);
const int N = 1e5 + 100;
int n, vis[300];
char s[N];
bool check(int x) {
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= x; ++i) {
    vis[s[i]]++;
  }
  for (int i = 1; i <= n - x; ++i) {
    if (s[i] == s[i + x]) continue;
    if (vis[s[i + x]] > 0) vis[s[i + x]]++;
    vis[s[i]]--;
  }
  for (int i = 'a'; i <= 'z'; ++i) {
    if (vis[i] > 0) return 1;
  }
  return 0;
}
int main() {
  cin >> s + 1;
  n = strlen(s + 1);
  int l = 1, r = n, ans = n;
  while (l <= r) {
    int mid = l + r >> 1;
    if (check(mid)) {
      ans = mid, r = mid - 1;
    } else
      l = mid + 1;
  }
  cout << ans << ("\n");
  return 0;
}
