#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> k(26, -1e9);
  string s;
  cin >> s;
  int n = (int)s.length();
  for (char c = 'a'; c <= 'z'; ++c) {
    int prev = -1;
    for (int i = 0; i < n; ++i) {
      if (s[i] == c) {
        k[c - 'a'] = max(i - prev, k[c - 'a']);
        prev = i;
      }
    }
    k[c - 'a'] = max(n - prev, k[c - 'a']);
  }
  int ans = n;
  for (int i = 0; i < 26; ++i) {
    if (k[i] != -1e9) {
      ans = min(ans, k[i]);
    }
  }
  cout << ans;
}

### Prompt

Please create a solution in Cpp to the following problem:

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> k(26, -1e9);
  string s;
  cin >> s;
  int n = (int)s.length();
  for (char c = 'a'; c <= 'z'; ++c) {
    int prev = -1;
    for (int i = 0; i < n; ++i) {
      if (s[i] == c) {
        k[c - 'a'] = max(i - prev, k[c - 'a']);
        prev = i;
      }
    }
    k[c - 'a'] = max(n - prev, k[c - 'a']);
  }
  int ans = n;
  for (int i = 0; i < 26; ++i) {
    if (k[i] != -1e9) {
      ans = min(ans, k[i]);
    }
  }
  cout << ans;
}

```