import io.StdIn._
object Main extends App {
    val Array(n,m,x) = readLine.split(" ").map(_.toInt)
    val as = readLine.split(" ").map(_.toInt)

    if (n == 1) println(0)
    else {
        var fees = (for(_ <- 0 to n) yield 0).toArray
        for (a <- as) fees = fees.updated(a, 1)

        val left_part = fees.take(x-1)
        val right_part = fees.drop(x)

        val min = math.min(left_part.sum, right_part.sum)
        println(min)
    }
    
}