import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val s = sc.next().toCharArray()


  val list = mutableListOf<Int>()
  for (c in 'a'..'z') {
    if (!s.contains(c)) {
      continue
    }
    var t = s
    var count = 0
    while (true) {
      if (t.groupBy { it }.size == 1) {
        break
      }

      val tmp = CharArray(t.size - 1) { ' ' }
      for (i in 0 until tmp.size) {
        if (t[i] == c || t[i+1] == c) {
          tmp[i] = c
        } else {
          tmp[i] = t[i]
        }
      }
      count++
      t = tmp
    }
    list.add(count)
  }

  println(list.min())
}