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 current isAscend cost =
        if current = 0 || current = n then
            cost
        else
            let cost = if Array.exists (fun x -> x = current) a then cost + 1 else cost
            if isAscend then
                solve (current + 1) isAscend cost
            else
                solve (current - 1) isAscend cost

    let ascendResult = solve x true 0
    let descendResult = solve x false 0
    min ascendResult descendResult |> stdout.WriteLine
    0
