fun main(args: Array<String>) {
    agc016a()
}

fun agc016a() {
    val s = readLine()!!

    val answer = s.toCharArray().distinct().map { char ->
        var curr = s.toCharArray()
        var cnt = 0
        while (curr.any { it != char }) {
            curr = curr.dropLast(1)
                .mapIndexed { index, c -> if (curr[index + 1] == char) char else c }.toCharArray()
            cnt++
        }
        cnt
    }.min()

    println(answer)
}
