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;
bool existDominantCharacter(const string &s, int k) {
  for (char c = 'a'; c <= 'z'; c++) {
    int countCharacter = count(s.begin(), s.begin() + k, c);
    bool exist = countCharacter > 0;
    if (!exist) {
      continue;
    }
    for (int i = k; i < s.size(); i++) {
      if (s[i] == c) {
        countCharacter++;
      }
      if (s[i - k] == c) {
        countCharacter--;
      }
      if (countCharacter <= 0) {
        exist = false;
        break;
      }
    }
    if (exist) {
      return true;
    }
  }
  return false;
}
int solve(const string &s) {
  int left = 1;
  int right = s.length();
  int bestSize = s.length();
  while (left <= right) {
    int mid = left + (right - left) / 2;
    if (existDominantCharacter(s, mid)) {
      bestSize = mid;
      right = mid - 1;
    } else {
      left = mid + 1;
    }
  }
  return bestSize;
}
int main() {
  string s;
  cin >> s;
  cout << solve(s) << endl;
  return 0;
}
