import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();// 料金所の数
        int x = sc.nextInt();// 今いる場所

        HashMap<Integer, Boolean> box = new HashMap<>();
        // 初期化
        for (int i = 0; i <= n; i++) {
            box.put(i, false);
        }

        for (int i = 0; i < m; i++) {
            int tmpShop = sc.nextInt();// 料金所の場所
            box.put(tmpShop, true);
        }

        int costRight = 0;// マスを右に移動
        for (int i = x; i <= n; i++) {
            if ((boolean)box.get(i) == true) costRight++;
        }

        int costLeft = 0;// マスを左に移動
        for (int i = x; i > 0; i--) {
            if ((boolean)box.get(i) == true) costLeft++;
        }

        System.out.println(Math.min(costLeft, costRight));
    }
} import java.util.*; util.* java public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();// 料金所の数
        int x = sc.nextInt();// 今いる場所

        HashMap<Integer, Boolean> box = new HashMap<>();
        // 初期化
        for (int i = 0; i <= n; i++) {
            box.put(i, false);
        }

        for (int i = 0; i < m; i++) {
            int tmpShop = sc.nextInt();// 料金所の場所
            box.put(tmpShop, true);
        }

        int costRight = 0;// マスを右に移動
        for (int i = x; i <= n; i++) {
            if ((boolean)box.get(i) == true) costRight++;
        }

        int costLeft = 0;// マスを左に移動
        for (int i = x; i > 0; i--) {
            if ((boolean)box.get(i) == true) costLeft++;
        }

        System.out.println(Math.min(costLeft, costRight));
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();// 料金所の数
        int x = sc.nextInt();// 今いる場所

        HashMap<Integer, Boolean> box = new HashMap<>();
        // 初期化
        for (int i = 0; i <= n; i++) {
            box.put(i, false);
        }

        for (int i = 0; i < m; i++) {
            int tmpShop = sc.nextInt();// 料金所の場所
            box.put(tmpShop, true);
        }

        int costRight = 0;// マスを右に移動
        for (int i = x; i <= n; i++) {
            if ((boolean)box.get(i) == true) costRight++;
        }

        int costLeft = 0;// マスを左に移動
        for (int i = x; i > 0; i--) {
            if ((boolean)box.get(i) == true) costLeft++;
        }

        System.out.println(Math.min(costLeft, costRight));
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();// 料金所の数
        int x = sc.nextInt();// 今いる場所

        HashMap<Integer, Boolean> box = new HashMap<>();
        // 初期化
        for (int i = 0; i <= n; i++) {
            box.put(i, false);
        }

        for (int i = 0; i < m; i++) {
            int tmpShop = sc.nextInt();// 料金所の場所
            box.put(tmpShop, true);
        }

        int costRight = 0;// マスを右に移動
        for (int i = x; i <= n; i++) {
            if ((boolean)box.get(i) == true) costRight++;
        }

        int costLeft = 0;// マスを左に移動
        for (int i = x; i > 0; i--) {
            if ((boolean)box.get(i) == true) costLeft++;
        }

        System.out.println(Math.min(costLeft, costRight));
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc HashMap<Integer, Boolean> box = new HashMap<>(); box new HashMap<>() for (int i = 0; i <= n; i++) {
            box.put(i, false);
        } int i = 0; int i = 0; i 0 i <= n i n i++ i++ i {
            box.put(i, false);
        } {
            box.put(i, false);
        } box.put(i, false) box.put box i false for (int i = 0; i < m; i++) {
            int tmpShop = sc.nextInt();// 料金所の場所
            box.put(tmpShop, true);
        } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
            int tmpShop = sc.nextInt();// 料金所の場所
            box.put(tmpShop, true);
        } {
            int tmpShop = sc.nextInt();// 料金所の場所
            box.put(tmpShop, true);
        } int tmpShop = sc.nextInt(); tmpShop sc.nextInt() sc.nextInt sc box.put(tmpShop, true) box.put box tmpShop true int costRight = 0; costRight 0 for (int i = x; i <= n; i++) {
            if ((boolean)box.get(i) == true) costRight++;
        } int i = x; int i = x; i x i <= n i n i++ i++ i {
            if ((boolean)box.get(i) == true) costRight++;
        } {
            if ((boolean)box.get(i) == true) costRight++;
        } if ((boolean)box.get(i) == true) costRight++; (boolean)box.get(i) == true (boolean)box.get(i) box.get box i true costRight++ costRight int costLeft = 0; costLeft 0 for (int i = x; i > 0; i--) {
            if ((boolean)box.get(i) == true) costLeft++;
        } int i = x; int i = x; i x i > 0 i 0 i-- i-- i {
            if ((boolean)box.get(i) == true) costLeft++;
        } {
            if ((boolean)box.get(i) == true) costLeft++;
        } if ((boolean)box.get(i) == true) costLeft++; (boolean)box.get(i) == true (boolean)box.get(i) box.get box i true costLeft++ costLeft System.out.println(Math.min(costLeft, costRight)) System.out.println System.out System System.out Math.min(costLeft, costRight) Math.min Math costLeft costRight String[] args args public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();// 料金所の数
        int x = sc.nextInt();// 今いる場所

        HashMap<Integer, Boolean> box = new HashMap<>();
        // 初期化
        for (int i = 0; i <= n; i++) {
            box.put(i, false);
        }

        for (int i = 0; i < m; i++) {
            int tmpShop = sc.nextInt();// 料金所の場所
            box.put(tmpShop, true);
        }

        int costRight = 0;// マスを右に移動
        for (int i = x; i <= n; i++) {
            if ((boolean)box.get(i) == true) costRight++;
        }

        int costLeft = 0;// マスを左に移動
        for (int i = x; i > 0; i--) {
            if ((boolean)box.get(i) == true) costLeft++;
        }

        System.out.println(Math.min(costLeft, costRight));
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();// 料金所の数
        int x = sc.nextInt();// 今いる場所

        HashMap<Integer, Boolean> box = new HashMap<>();
        // 初期化
        for (int i = 0; i <= n; i++) {
            box.put(i, false);
        }

        for (int i = 0; i < m; i++) {
            int tmpShop = sc.nextInt();// 料金所の場所
            box.put(tmpShop, true);
        }

        int costRight = 0;// マスを右に移動
        for (int i = x; i <= n; i++) {
            if ((boolean)box.get(i) == true) costRight++;
        }

        int costLeft = 0;// マスを左に移動
        for (int i = x; i > 0; i--) {
            if ((boolean)box.get(i) == true) costLeft++;
        }

        System.out.println(Math.min(costLeft, costRight));
    }
} Main
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();// 料金所の数
        int x = sc.nextInt();// 今いる場所

        HashMap<Integer, Boolean> box = new HashMap<>();
        // 初期化
        for (int i = 0; i <= n; i++) {
            box.put(i, false);
        }

        for (int i = 0; i < m; i++) {
            int tmpShop = sc.nextInt();// 料金所の場所
            box.put(tmpShop, true);
        }

        int costRight = 0;// マスを右に移動
        for (int i = x; i <= n; i++) {
            if ((boolean)box.get(i) == true) costRight++;
        }

        int costLeft = 0;// マスを左に移動
        for (int i = x; i > 0; i--) {
            if ((boolean)box.get(i) == true) costLeft++;
        }

        System.out.println(Math.min(costLeft, costRight));
    }
}
