eolymp
bolt
Try our new interface for solving problems
Problems

Distance Between Lletters

Distance Between Lletters

You are given a string \textbf{s} containing lower-case letters of Latin alphabet. We define a distance between two symbols \textbf{s_i}, \textbf{s_j} of this string as difference between their positions, i.e. |\textbf{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. \InputFile The single line of input file contains a string \textbf{s}. The length of this string does not exceed \textbf{5·10^6}. \OutputFile Output one number, minimal distance between equal symbols. If there are no pairs of equal symbols in the string, output the number \textbf{0}.
Time limit 1 second
Memory limit 64 MiB
Input example #1
abcacba
Output example #1
2
Source International Collegiate Programming Contest, Ukraine, Quarter-Final,May 19, 2011