import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        int[] a = new int[n+1];

        for(int i=0; i<m; i++) {
            a[Integer.parseInt(sc.next())]++;
        }
        int ton = 0;
        int to0 = 0;
        for(int i=x+1; i<=n; i++) {
            if(a[i] != 0) ton++;  
        }
        for(int i=x-1; i>=0; i--) {
            if(a[i] != 0) to0++;  
        }
        System.out.println(min(ton, to0));
    }
    public static int min(int a, int b) {
        if(a <= b) return a;
        else return b;
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        int[] a = new int[n+1];

        for(int i=0; i<m; i++) {
            a[Integer.parseInt(sc.next())]++;
        }
        int ton = 0;
        int to0 = 0;
        for(int i=x+1; i<=n; i++) {
            if(a[i] != 0) ton++;  
        }
        for(int i=x-1; i>=0; i--) {
            if(a[i] != 0) to0++;  
        }
        System.out.println(min(ton, to0));
    }
    public static int min(int a, int b) {
        if(a <= b) return a;
        else return b;
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        int[] a = new int[n+1];

        for(int i=0; i<m; i++) {
            a[Integer.parseInt(sc.next())]++;
        }
        int ton = 0;
        int to0 = 0;
        for(int i=x+1; i<=n; i++) {
            if(a[i] != 0) ton++;  
        }
        for(int i=x-1; i>=0; i--) {
            if(a[i] != 0) to0++;  
        }
        System.out.println(min(ton, to0));
    } main {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        int[] a = new int[n+1];

        for(int i=0; i<m; i++) {
            a[Integer.parseInt(sc.next())]++;
        }
        int ton = 0;
        int to0 = 0;
        for(int i=x+1; i<=n; i++) {
            if(a[i] != 0) ton++;  
        }
        for(int i=x-1; i>=0; i--) {
            if(a[i] != 0) to0++;  
        }
        System.out.println(min(ton, to0));
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int m = Integer.parseInt(sc.next()); m Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int x = Integer.parseInt(sc.next()); x Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int[] a = new int[n+1]; a new int[n+1] n+1 n 1 for(int i=0; i<m; i++) {
            a[Integer.parseInt(sc.next())]++;
        } int i=0; int i=0; i 0 i<m i m i++ i++ i {
            a[Integer.parseInt(sc.next())]++;
        } {
            a[Integer.parseInt(sc.next())]++;
        } a[Integer.parseInt(sc.next())]++ a[Integer.parseInt(sc.next())] a Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int ton = 0; ton 0 int to0 = 0; to0 0 for(int i=x+1; i<=n; i++) {
            if(a[i] != 0) ton++;  
        } int i=x+1; int i=x+1; i x+1 x 1 i<=n i n i++ i++ i {
            if(a[i] != 0) ton++;  
        } {
            if(a[i] != 0) ton++;  
        } if(a[i] != 0) ton++; a[i] != 0 a[i] a i 0 ton++ ton for(int i=x-1; i>=0; i--) {
            if(a[i] != 0) to0++;  
        } int i=x-1; int i=x-1; i x-1 x 1 i>=0 i 0 i-- i-- i {
            if(a[i] != 0) to0++;  
        } {
            if(a[i] != 0) to0++;  
        } if(a[i] != 0) to0++; a[i] != 0 a[i] a i 0 to0++ to0 System.out.println(min(ton, to0)) System.out.println System.out System System.out min(ton, to0) min ton to0 String[] args args public static int min(int a, int b) {
        if(a <= b) return a;
        else return b;
    } min {
        if(a <= b) return a;
        else return b;
    } if(a <= b) return a;
        else return b; a <= b a b return a; a return b; b int a a int b b public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        int[] a = new int[n+1];

        for(int i=0; i<m; i++) {
            a[Integer.parseInt(sc.next())]++;
        }
        int ton = 0;
        int to0 = 0;
        for(int i=x+1; i<=n; i++) {
            if(a[i] != 0) ton++;  
        }
        for(int i=x-1; i>=0; i--) {
            if(a[i] != 0) to0++;  
        }
        System.out.println(min(ton, to0));
    }
    public static int min(int a, int b) {
        if(a <= b) return a;
        else return b;
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        int[] a = new int[n+1];

        for(int i=0; i<m; i++) {
            a[Integer.parseInt(sc.next())]++;
        }
        int ton = 0;
        int to0 = 0;
        for(int i=x+1; i<=n; i++) {
            if(a[i] != 0) ton++;  
        }
        for(int i=x-1; i>=0; i--) {
            if(a[i] != 0) to0++;  
        }
        System.out.println(min(ton, to0));
    }
    public static int min(int a, int b) {
        if(a <= b) return a;
        else return b;
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        int[] a = new int[n+1];

        for(int i=0; i<m; i++) {
            a[Integer.parseInt(sc.next())]++;
        }
        int ton = 0;
        int to0 = 0;
        for(int i=x+1; i<=n; i++) {
            if(a[i] != 0) ton++;  
        }
        for(int i=x-1; i>=0; i--) {
            if(a[i] != 0) to0++;  
        }
        System.out.println(min(ton, to0));
    }
    public static int min(int a, int b) {
        if(a <= b) return a;
        else return b;
    }
}
