Distance Between Letters#2158

Distance Between Letters

1 second
64 megabytes
Very easy

You are given a string containing lowercase Latin letters. The distance between two symbols s_i and s_j in this string is the difference between their positions, i.e., |j - i|. Consider all pairs of identical symbols located at different positions and calculate the distance for each such pair.

Write a program to determine the minimum of all such distances.

Input

The input contains a single string . The length of the string does not exceed 5 \cdot 10^6.

Output

Output a single number: the minimal distance between identical symbols. If there are no pairs of identical symbols in the string, output 0.

Examples

Example 1

Loading
Loading