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;
vector<vector<int>> freq;
string s;
int n;
bool check(int mid) {
  for (int i = 0; i < 26; i++) {
    int flag = 1;
    for (int end = mid; end <= n; end++) {
      int start = end - mid + 1;
      if (freq[i][end] - freq[i][start - 1] == 0) {
        flag = 0;
        break;
      }
    }
    if (flag) return true;
  }
  return false;
}
int main() {
  cin >> s;
  n = s.length();
  freq = vector<vector<int>>(26, vector<int>(n + 1));
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 26; j++) {
      if (s[i - 1] - 'a' == j)
        freq[j][i] = freq[j][i - 1] + 1;
      else
        freq[j][i] = freq[j][i - 1];
    }
  }
  int start = 0, end = n;
  while (end - start > 1) {
    int mid = (start + end) / 2;
    if (check(mid))
      end = mid;
    else
      start = mid;
  }
  cout << end << "\n";
  return 0;
}
