#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
char s[N];
int n, a[26], k[26];
int main() {
  gets(s + 1);
  n = strlen(s + 1);
  memset(k, 0, sizeof k);
  memset(a, 0, sizeof a);
  for (int i = 1; i <= n; ++i) {
    k[s[i] - 'a'] = max(k[s[i] - 'a'], i - a[s[i] - 'a']);
    a[s[i] - 'a'] = i;
  }
  for (int i = 0; i < 26; ++i) k[i] = max(k[i], n + 1 - a[i]);
  int ans = n;
  for (int i = 0; i < 26; ++i) ans = min(k[i], ans);
  printf("%d\n", ans);
  return 0;
}

### Prompt

In Cpp, your task is to solve 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;
const int N = 1e5 + 10;
char s[N];
int n, a[26], k[26];
int main() {
  gets(s + 1);
  n = strlen(s + 1);
  memset(k, 0, sizeof k);
  memset(a, 0, sizeof a);
  for (int i = 1; i <= n; ++i) {
    k[s[i] - 'a'] = max(k[s[i] - 'a'], i - a[s[i] - 'a']);
    a[s[i] - 'a'] = i;
  }
  for (int i = 0; i < 26; ++i) k[i] = max(k[i], n + 1 - a[i]);
  int ans = n;
  for (int i = 0; i < 26; ++i) ans = min(k[i], ans);
  printf("%d\n", ans);
  return 0;
}

```