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;
string s;
bool can(int k) {
  vector<int> kol(26);
  vector<bool> norm(26, true);
  for (int i = 0; i < k; i++) {
    kol[s[i] - 'a']++;
  }
  for (int i = 0; i < 26; i++) {
    if (!kol[i]) {
      norm[i] = false;
    }
  }
  for (int i = k; i < s.size(); i++) {
    kol[s[i - k] - 'a']--;
    kol[s[i] - 'a']++;
    for (int j = 0; j < 26; j++) {
      if (!kol[j]) {
        norm[j] = false;
      }
    }
  }
  for (int i = 0; i < 26; i++) {
    if (norm[i]) {
      return true;
    }
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> s;
  int l = -1;
  int r = s.size();
  int m;
  while (l + 1 < r) {
    m = (l + r) / 2;
    if (can(m)) {
      r = m;
    } else {
      l = m;
    }
  }
  cout << r;
}
