import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int X = scanner.nextInt() - 1;
    Set<Integer> tolls = new HashSet<>();
    for (int i = 0; i < M; i++) tolls.add(scanner.nextInt() - 1);
    int left = 0, right = 0;
    for (int i = X; i >= 0; i--) if (tolls.contains(i)) left++;
    for (int i = X; i < N; i++) if (tolls.contains(i)) right++;
    System.out.println(Math.min(left, right));
  }
} import java.util.HashSet; HashSet java.util import java.util.Scanner; Scanner java.util import java.util.Set; Set java.util public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int X = scanner.nextInt() - 1;
    Set<Integer> tolls = new HashSet<>();
    for (int i = 0; i < M; i++) tolls.add(scanner.nextInt() - 1);
    int left = 0, right = 0;
    for (int i = X; i >= 0; i--) if (tolls.contains(i)) left++;
    for (int i = X; i < N; i++) if (tolls.contains(i)) right++;
    System.out.println(Math.min(left, right));
  }
} Main public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int X = scanner.nextInt() - 1;
    Set<Integer> tolls = new HashSet<>();
    for (int i = 0; i < M; i++) tolls.add(scanner.nextInt() - 1);
    int left = 0, right = 0;
    for (int i = X; i >= 0; i--) if (tolls.contains(i)) left++;
    for (int i = X; i < N; i++) if (tolls.contains(i)) right++;
    System.out.println(Math.min(left, right));
  } main {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int X = scanner.nextInt() - 1;
    Set<Integer> tolls = new HashSet<>();
    for (int i = 0; i < M; i++) tolls.add(scanner.nextInt() - 1);
    int left = 0, right = 0;
    for (int i = X; i >= 0; i--) if (tolls.contains(i)) left++;
    for (int i = X; i < N; i++) if (tolls.contains(i)) right++;
    System.out.println(Math.min(left, right));
  } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = scanner.nextInt(); N scanner.nextInt() scanner.nextInt scanner int M = scanner.nextInt(); M scanner.nextInt() scanner.nextInt scanner int X = scanner.nextInt() - 1; X scanner.nextInt() - 1 scanner.nextInt() scanner.nextInt scanner 1 Set<Integer> tolls = new HashSet<>(); tolls new HashSet<>() for (int i = 0; i < M; i++) tolls.add(scanner.nextInt() - 1); int i = 0; int i = 0; i 0 i < M i M i++ i++ i tolls.add(scanner.nextInt() - 1); tolls.add(scanner.nextInt() - 1) tolls.add tolls scanner.nextInt() - 1 scanner.nextInt() scanner.nextInt scanner 1 int left = 0 left 0 right = 0; right 0 for (int i = X; i >= 0; i--) if (tolls.contains(i)) left++; int i = X; int i = X; i X i >= 0 i 0 i-- i-- i if (tolls.contains(i)) left++; if (tolls.contains(i)) left++; tolls.contains(i) tolls.contains tolls i left++ left for (int i = X; i < N; i++) if (tolls.contains(i)) right++; int i = X; int i = X; i X i < N i N i++ i++ i if (tolls.contains(i)) right++; if (tolls.contains(i)) right++; tolls.contains(i) tolls.contains tolls i right++ right System.out.println(Math.min(left, right)) System.out.println System.out System System.out Math.min(left, right) Math.min Math left right String[] args args public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int X = scanner.nextInt() - 1;
    Set<Integer> tolls = new HashSet<>();
    for (int i = 0; i < M; i++) tolls.add(scanner.nextInt() - 1);
    int left = 0, right = 0;
    for (int i = X; i >= 0; i--) if (tolls.contains(i)) left++;
    for (int i = X; i < N; i++) if (tolls.contains(i)) right++;
    System.out.println(Math.min(left, right));
  }
} public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int X = scanner.nextInt() - 1;
    Set<Integer> tolls = new HashSet<>();
    for (int i = 0; i < M; i++) tolls.add(scanner.nextInt() - 1);
    int left = 0, right = 0;
    for (int i = X; i >= 0; i--) if (tolls.contains(i)) left++;
    for (int i = X; i < N; i++) if (tolls.contains(i)) right++;
    System.out.println(Math.min(left, right));
  }
} Main
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int X = scanner.nextInt() - 1;
    Set<Integer> tolls = new HashSet<>();
    for (int i = 0; i < M; i++) tolls.add(scanner.nextInt() - 1);
    int left = 0, right = 0;
    for (int i = X; i >= 0; i--) if (tolls.contains(i)) left++;
    for (int i = X; i < N; i++) if (tolls.contains(i)) right++;
    System.out.println(Math.min(left, right));
  }
}
