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 check(string s, int k) {
  bool flag = 0;
  map<char, int> m;
  int count = 0;
  for (int i = 0; i < k; i++) {
    m[s[i]]++;
    count++;
  }
  for (int i = k; i < s.size(); i++) {
    if (m[s[i]] > 0) {
      m[s[i]]++;
      count++;
    }
    if (m[s[i - k]] > 0) {
      m[s[i - k]]--;
      count--;
    }
    if (count == 0) return false;
  }
  return true;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  int st = 1;
  int e = s.size();
  int res;
  while (st <= e) {
    int mid = (st + e) / 2;
    if (check(s, mid)) {
      res = mid;
      e = mid - 1;
    } else {
      st = mid + 1;
    }
  }
  cout << res << "\n";
  return 0;
}
