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;
int maxcnt;
int main() {
  string s;
  cin >> s;
  set<char> set1;
  for (int i = 0; i < s.size(); ++i) {
    set1.insert(s[i]);
  }
  if (set1.size() == 1) {
    cout << 1;
    return 0;
  }
  long long max = 0;
  long long mini = 1e13;
  for (auto x : set1) {
    int f1 = 0;
    int f2 = 0;
    maxcnt = 0;
    while (f2 < s.size()) {
      if (s[f1] != x) {
        for (int i = 0; i < s.size(); ++i) {
          if (s[f1] != x) {
            f1++;
          } else {
            break;
          }
        }
        maxcnt = f1 + 1;
      }
      f2 = f1 + 1;
      for (int i = f2; i < s.size(); ++i) {
        if (s[i] != x) {
          f2++;
        } else {
          break;
        }
      }
      if ((f2 - f1) > maxcnt) maxcnt = (f2 - f1);
      f1 = f2;
    }
    if (maxcnt < mini) mini = maxcnt;
  }
  if (mini > s.size() / 2 + 1) {
    cout << s.size() / 2 + 1;
  } else {
    cout << mini;
  }
}
