fun main(args:Array<String>) {
    val s = readLine()!!.map { it.toString().toInt() }
    val idx = readLine()!!.toLong() - 1
    if(idx <= 100 && s.take(idx.toInt()+1).all { it == 1 }) {
        println(1)
    } else {
        println(s.first { it != 1 })
    }
}