import kotlin.math.min

fun main(args: Array<String>) {
    val s = readString()

    var ans = Int.MAX_VALUE
    for (c in 'a'..'z') {
        if (!s.contains(c)) continue
        ans = min(ans, s.split(c).maxBy { it.length }!!.length)
    }
    println(ans)
}

// read
fun readString() = readLine()!!