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 A;
vector<int> Pos[30];
int main() {
  cin >> A;
  for (int i = 0; i <= 25; i++) Pos[i].push_back(0);
  for (int i = 0; i < A.size(); i++) {
    Pos[A[i] - 'a'].push_back(i + 1);
  }
  for (int i = 0; i <= 25; i++) Pos[i].push_back(A.size() + 1);
  int k = A.size();
  for (int i = 0; i <= 25; i++) {
    if (Pos[i].size() == 2) continue;
    int prev = Pos[i][0], curr = 0, df = -1;
    for (int j = 1; j < Pos[i].size(); j++) {
      curr = Pos[i][j];
      df = max(df, curr - prev);
      prev = curr;
    }
    if (df > 0) k = min(k, df);
  }
  cout << k << endl;
  return 0;
}
