You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c.

You have to find minimum k such that there exists at least one k-dominant character.

Input

The first line contains string s consisting of lowercase Latin letters (1 ≤ |s| ≤ 100000).

Output

Print one number — the minimum value of k such that there exists at least one k-dominant character.

Examples

Input

abacaba


Output

2


Input

zzzzz


Output

1


Input

abcde


Output

3
#include <bits/stdc++.h>
using namespace std;
template <class T>
bool uin(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool uax(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
const long long maxn = 1000001, mod = 1e9 + 7;
int n;
string s;
bool check(int m) {
  int st[26];
  memset(st, 0, sizeof(st));
  int hsh[26];
  bool hsh1[26];
  memset(hsh, 0, sizeof(hsh));
  memset(hsh1, true, sizeof(hsh1));
  for (int i = 0; i < m; i++) {
    st[s[i] - 'a'] = 1;
    hsh[s[i] - 'a']++;
  }
  vector<int> v;
  for (int i = 0; i < 26; i++) {
    if (st[i]) v.push_back(i + 'a');
  }
  for (int i = m; i < s.size(); i++) {
    hsh[s[i] - 'a']++;
    hsh[s[i - m] - 'a']--;
    for (auto it : v) {
      if (hsh[it - 'a'] == 0) hsh1[it - 'a'] = false;
    }
  }
  for (auto it : v) {
    if (hsh1[it - 'a'] == true) return true;
  }
  return false;
}
int bs() {
  int l = 1, r = n;
  int ans;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (check(mid)) {
      ans = mid;
      r = mid - 1;
    } else {
      l = mid + 1;
    }
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> s;
  n = s.size();
  cout << bs();
}
