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;
char s[1000005];
int main() {
  cin >> s;
  int n = strlen(s);
  int l = 1;
  int h = n;
  int mid = 2;
  int i;
  int ans = 0;
  while (l <= h) {
    int mid = (l + h) / 2;
    int a[26];
    int fl[26];
    for (i = 0; i < 26; i++) {
      a[i] = 0;
      fl[i] = 0;
    }
    for (i = 0; i < mid; i++) {
      int x = s[i] - 'a';
      a[x]++;
      fl[x] = 1;
    }
    int co = 0;
    for (i = mid; i < n; i++) {
      int x = s[i] - 'a';
      a[x]++;
      x = s[co] - 'a';
      a[x]--;
      if ((a[x]) == 0) fl[x] = 0;
      co++;
    }
    int u = 0;
    for (i = 0; i < 26; i++)
      if (fl[i]) {
        u++;
      }
    if (u == 0) {
      l = mid + 1;
    } else {
      ans = mid;
      h = mid - 1;
    }
  }
  cout << ans << endl;
  return 0;
}
