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 last[26 + 5], ans[26 + 5];
bool vis[26 + 5];
int main() {
  int len, i, j, minn = 1e9, minp;
  string s;
  cin >> s;
  len = s.length();
  memset(last, 0, sizeof(last));
  memset(ans, 0, sizeof(ans));
  minn = len / 2 + 1;
  for (i = 0; i < len; i++)
    if (last[int(s[i] - 'a')] == 0) {
      last[int(s[i] - 'a')] = i + 1;
    } else {
      ans[int(s[i] - 'a')] =
          max(ans[int(s[i] - 'a')], i + 1 - last[int(s[i] - 'a')]);
      last[int(s[i] - 'a')] = i + 1;
    }
  memset(vis, false, sizeof(vis));
  for (i = 0; i < len; i++)
    if (!vis[int(s[i] - 'a')]) {
      ans[int(s[i] - 'a')] = max(ans[int(s[i] - 'a')], i + 1);
      vis[int(s[i] - 'a')] = true;
    }
  memset(vis, false, sizeof(vis));
  for (i = len - 1; i >= 0; i--)
    if (!vis[int(s[i] - 'a')]) {
      ans[int(s[i] - 'a')] = max(ans[int(s[i] - 'a')], len - i);
      vis[int(s[i] - 'a')] = true;
    }
  for (i = 0; i < 26; i++)
    if (ans[i] != 0) {
      minn = min(minn, ans[i]);
      minp = i;
    }
  cout << minn << endl;
}
