open System

[<EntryPoint>]
let main _ =
    let [| n; m; x; |] = stdin.ReadLine().Split() |> Array.map int
    let a = stdin.ReadLine().Split() |> Array.map int
    let rec solve start ok ng =
        if abs (ok - ng) = 1 then
            ok
        else
            let mid = (ok + ng) / 2
            if start > a.[mid] then
                solve start ok mid
            else
                solve start mid ng

    let result = (solve x m 0) - 1
    min result (m - result) |> stdout.WriteLine
    0
