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 main() {
  string s;
  cin >> s;
  string a = "abcdefghijklmnopqrstuvwxyz";
  set<int> maxes;
  for (int i = 0; i < a.length(); i++) {
    if (s.find(a[i]) == string::npos) {
      continue;
    } else {
      int max = 0;
      int first = -1, current = -1, next = -1, last = -1;
      for (int j = 0; j < s.length(); j++) {
        if (s[j] == a[i]) {
          last = j;
          if (first == -1) {
            first = j;
            current = first;
          } else if (next == -1) {
            next = j;
          }
          if (next - current - 1 > max && current != -1 && next != -1) {
            max = next - current - 1;
          }
          if (first != -1 && next != -1) {
            current = next;
            next = -1;
          }
        }
      }
      if (first > max) {
        max = first;
      }
      if ((s.length() - 1) - last > max) {
        max = (s.length() - 1) - last;
      }
      maxes.insert(max + 1);
    }
  }
  for (auto m : maxes) {
    cout << m << endl;
    break;
  }
}
