import io.StdIn.readLine
object Main extends App {
  val s = readLine
  println(solve(s))

  def solve(s: String) = {
    (for (ab <- 'a' to 'z') yield {
      s.split(ab).map(_.length).max
    }).min
  }
}
