Distance Between Lletters
Very easy
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
You are given a string s containing lower-case letters of Latin alphabet. We define a distance between two symbols s_i, s_j of this string as difference between their positions, i.e. |j - i|. Let us consider all pairs of equal symbols located in different positions, and calculate distances between symbols of each pair.
Write the program for determining minimum of all such distances.
Input
The single line of input file contains a string s. The length of this string does not exceed 5·10^6.
Output
Output one number, minimal distance between equal symbols. If there are no pairs of equal symbols in the string, output the number 0.
Examples
Input #1
Answer #1
Submissions 1K
Acceptance rate 25%