object Main extends App {
  def count(str: String, main: Char): Int = {
    var t = str
    var count = 0

    while (!ok(t)) {
      t = t.zip(t.tail).map(_ match {
        case (`main`, _) => main
        case (_, `main`) => main
        case (cur, _) => cur
      }).mkString
      count = count + 1
    }
    count
  }

  def ok(str: String): Boolean = str.distinct.length <= 1

  def calc(str: String): Int = {
    str.map(c => count(str, c)).min
  }

  val sc = new java.util.Scanner(System.in)
  val str = sc.nextLine()
  println(calc(str))
}