import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val s = sc.next
  val distinct = s.distinct

  val res = distinct.map(loop(_, s).max).min
  println(res)

  def loop(ch: Char, str: String, vec: Vector[Int] = Vector.empty): Vector[Int] = {
    str.foldLeft(vec){ case (acc, c) =>
      val (tr, fa) = str.span(_ != ch)
      if(fa.isEmpty) vec :+ tr.length
      else loop(ch, fa.tail, vec :+ tr.length)
    }
  }
}