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(int argc, char const *argv[]) {
  int i, j;
  string s;
  cin >> s;
  vector<int> pre(26, -1);
  vector<int> num(26, -1);
  for (i = 0; i < s.size(); i++) {
    int it = s[i] - 'a';
    if (pre[it] != -1)
      num[it] = max(num[it], i - pre[it]);
    else
      num[it] = i + 1;
    pre[it] = i;
  }
  for (i = 0; i < 26; i++)
    num[i] = max(num[i], (int)(strlen(s.c_str()) - pre[i]));
  int ans = 1000000000;
  for (i = 0; i < 26; i++)
    if (num[i] != 0) ans = min(ans, num[i]);
  cout << ans;
  return 0;
}
