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;
string s;
bool simulate(int big) {
  int i = 0, j = 0;
  int arr[26];
  bool check[26];
  memset(arr, 0, sizeof(arr));
  memset(check, false, sizeof(check));
  for (j = 0; j < big && j < s.length(); ++j) {
    arr[s[j] - 'a']++;
    check[s[j] - 'a'] = true;
  }
  while (j < s.length()) {
    arr[s[i] - 'a']--;
    ++i;
    arr[s[j] - 'a']++;
    for (int k = 0; k < 26; ++k) {
      if (check[k] == true && arr[k] <= 0) {
        check[k] = false;
      }
    }
    j++;
  }
  for (int k = 0; k < 26; ++k) {
    if (check[k]) {
      return true;
    }
  }
  return false;
}
int main() {
  cin >> s;
  int l = 0, r = 2e5, m;
  while (l < r) {
    m = (l + r) / 2;
    if (simulate(m)) {
      r = m;
    } else {
      l = m + 1;
    }
  }
  cout << l << endl;
  return 0;
}
