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;
int n;
map<char, int> cubeta;
map<char, bool> candidato;
bool f(int k) {
  for (char i = 'a'; i <= 'z'; i++) {
    cubeta[i] = 0;
    candidato[i] = true;
  }
  int ini = 0, fin = 0;
  for (fin = 0; fin < k; fin++) {
    cubeta[s[fin]]++;
  }
  int posibles_candidatos = (int)('z' - 'a' + 1);
  for (char i = 'a'; i <= 'z'; i++) {
    if (cubeta[i] == 0) {
      candidato[i] = false;
      posibles_candidatos--;
    }
  }
  while (posibles_candidatos > 0 && fin < n) {
    cubeta[s[fin]]++;
    cubeta[s[ini]]--;
    if (cubeta[s[ini]] == 0) {
      if (candidato[s[ini]]) posibles_candidatos--;
      candidato[s[ini]] = false;
    }
    ini++;
    fin++;
  }
  return (posibles_candidatos > 0);
}
int busqueda_bin(int ini, int fin) {
  if (ini == fin) {
    return ini;
  }
  int medio = (ini + fin) / 2;
  if (f(medio)) {
    return busqueda_bin(ini, medio);
  }
  return busqueda_bin(medio + 1, fin);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> s;
  n = s.size();
  cout << busqueda_bin(1, n) << "\n";
  return 0;
}
