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();
        int cost = 0;
        int cost2 = 0;
        boolean[] a = new boolean[n+1];

        Arrays.fill(a,false);

        for(int i = 0;i<m;i++){
            int num = sc.nextInt();
            a[num] = true;
        }

        for(int i = x+1;i<=n;i++){
            //System.out.println("cost : " + i);
            if(a[i]){
                cost++;
            }
        }

        for(int i = x-1;i>=0;i--){
            //System.out.println("cost2 : " + i);
            if(a[i]){
                cost2++;
               // System.out.println()
            }
        }
       // System.out.println(cost);
        //System.out.println(cost2);
        System.out.println(Math.min(cost,cost2));
        
    }
} 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();
        int cost = 0;
        int cost2 = 0;
        boolean[] a = new boolean[n+1];

        Arrays.fill(a,false);

        for(int i = 0;i<m;i++){
            int num = sc.nextInt();
            a[num] = true;
        }

        for(int i = x+1;i<=n;i++){
            //System.out.println("cost : " + i);
            if(a[i]){
                cost++;
            }
        }

        for(int i = x-1;i>=0;i--){
            //System.out.println("cost2 : " + i);
            if(a[i]){
                cost2++;
               // System.out.println()
            }
        }
       // System.out.println(cost);
        //System.out.println(cost2);
        System.out.println(Math.min(cost,cost2));
        
    }
} 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();
        int cost = 0;
        int cost2 = 0;
        boolean[] a = new boolean[n+1];

        Arrays.fill(a,false);

        for(int i = 0;i<m;i++){
            int num = sc.nextInt();
            a[num] = true;
        }

        for(int i = x+1;i<=n;i++){
            //System.out.println("cost : " + i);
            if(a[i]){
                cost++;
            }
        }

        for(int i = x-1;i>=0;i--){
            //System.out.println("cost2 : " + i);
            if(a[i]){
                cost2++;
               // System.out.println()
            }
        }
       // System.out.println(cost);
        //System.out.println(cost2);
        System.out.println(Math.min(cost,cost2));
        
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();
        int cost = 0;
        int cost2 = 0;
        boolean[] a = new boolean[n+1];

        Arrays.fill(a,false);

        for(int i = 0;i<m;i++){
            int num = sc.nextInt();
            a[num] = true;
        }

        for(int i = x+1;i<=n;i++){
            //System.out.println("cost : " + i);
            if(a[i]){
                cost++;
            }
        }

        for(int i = x-1;i>=0;i--){
            //System.out.println("cost2 : " + i);
            if(a[i]){
                cost2++;
               // System.out.println()
            }
        }
       // System.out.println(cost);
        //System.out.println(cost2);
        System.out.println(Math.min(cost,cost2));
        
    } 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 int cost = 0; cost 0 int cost2 = 0; cost2 0 boolean[] a = new boolean[n+1]; a new boolean[n+1] n+1 n 1 Arrays.fill(a,false) Arrays.fill Arrays a false for(int i = 0;i<m;i++){
            int num = sc.nextInt();
            a[num] = true;
        } int i = 0; int i = 0; i 0 i<m i m i++ i++ i {
            int num = sc.nextInt();
            a[num] = true;
        } {
            int num = sc.nextInt();
            a[num] = true;
        } int num = sc.nextInt(); num sc.nextInt() sc.nextInt sc a[num] = true a[num] a num true for(int i = x+1;i<=n;i++){
            //System.out.println("cost : " + i);
            if(a[i]){
                cost++;
            }
        } int i = x+1; int i = x+1; i x+1 x 1 i<=n i n i++ i++ i {
            //System.out.println("cost : " + i);
            if(a[i]){
                cost++;
            }
        } {
            //System.out.println("cost : " + i);
            if(a[i]){
                cost++;
            }
        } if(a[i]){
                cost++;
            } a[i] a i {
                cost++;
            } cost++ cost for(int i = x-1;i>=0;i--){
            //System.out.println("cost2 : " + i);
            if(a[i]){
                cost2++;
               // System.out.println()
            }
        } int i = x-1; int i = x-1; i x-1 x 1 i>=0 i 0 i-- i-- i {
            //System.out.println("cost2 : " + i);
            if(a[i]){
                cost2++;
               // System.out.println()
            }
        } {
            //System.out.println("cost2 : " + i);
            if(a[i]){
                cost2++;
               // System.out.println()
            }
        } if(a[i]){
                cost2++;
               // System.out.println()
            } a[i] a i {
                cost2++;
               // System.out.println()
            } cost2++ cost2 System.out.println(Math.min(cost,cost2)) System.out.println System.out System System.out Math.min(cost,cost2) Math.min Math cost cost2 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();
        int cost = 0;
        int cost2 = 0;
        boolean[] a = new boolean[n+1];

        Arrays.fill(a,false);

        for(int i = 0;i<m;i++){
            int num = sc.nextInt();
            a[num] = true;
        }

        for(int i = x+1;i<=n;i++){
            //System.out.println("cost : " + i);
            if(a[i]){
                cost++;
            }
        }

        for(int i = x-1;i>=0;i--){
            //System.out.println("cost2 : " + i);
            if(a[i]){
                cost2++;
               // System.out.println()
            }
        }
       // System.out.println(cost);
        //System.out.println(cost2);
        System.out.println(Math.min(cost,cost2));
        
    }
} 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();
        int cost = 0;
        int cost2 = 0;
        boolean[] a = new boolean[n+1];

        Arrays.fill(a,false);

        for(int i = 0;i<m;i++){
            int num = sc.nextInt();
            a[num] = true;
        }

        for(int i = x+1;i<=n;i++){
            //System.out.println("cost : " + i);
            if(a[i]){
                cost++;
            }
        }

        for(int i = x-1;i>=0;i--){
            //System.out.println("cost2 : " + i);
            if(a[i]){
                cost2++;
               // System.out.println()
            }
        }
       // System.out.println(cost);
        //System.out.println(cost2);
        System.out.println(Math.min(cost,cost2));
        
    }
} 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();
        int cost = 0;
        int cost2 = 0;
        boolean[] a = new boolean[n+1];

        Arrays.fill(a,false);

        for(int i = 0;i<m;i++){
            int num = sc.nextInt();
            a[num] = true;
        }

        for(int i = x+1;i<=n;i++){
            //System.out.println("cost : " + i);
            if(a[i]){
                cost++;
            }
        }

        for(int i = x-1;i>=0;i--){
            //System.out.println("cost2 : " + i);
            if(a[i]){
                cost2++;
               // System.out.println()
            }
        }
       // System.out.println(cost);
        //System.out.println(cost2);
        System.out.println(Math.min(cost,cost2));
        
    }
}
