There is an array with n elements a1, a2, ..., an and the number x.

In one operation you can select some i (1 ≤ i ≤ n) and replace element ai with ai & x, where & denotes the [bitwise and](https://en.wikipedia.org/wiki/Bitwise_operation#AND) operation.

You want the array to have at least two equal elements after applying some operations (possibly, none). In other words, there should be at least two distinct indices i ≠ j such that ai = aj. Determine whether it is possible to achieve and, if possible, the minimal number of operations to apply.

Input

The first line contains integers n and x (2 ≤ n ≤ 100 000, 1 ≤ x ≤ 100 000), number of elements in the array and the number to and with.

The second line contains n integers ai (1 ≤ ai ≤ 100 000), the elements of the array.

Output

Print a single integer denoting the minimal number of operations to do, or -1, if it is impossible.

Examples

Input

4 3
1 2 3 7


Output

1


Input

2 228
1 1


Output

0


Input

3 7
1 2 3


Output

-1

Note

In the first example one can apply the operation to the last element of the array. That replaces 7 with 3, so we achieve the goal in one move.

In the second example the array already has two equal elements.

In the third example applying the operation won't change the array at all, so it is impossible to make some pair of elements equal.

import org.w3c.dom.ls.LSOutput;

import java.util.*;
import java.util.function.IntBinaryOperator;


public class Example {
    static long[][] dp;
    //  static    int[]  ar;
    static int mod = 1000000000 + 7;
    static long[] ans = new long[100000 + 1];
    static List<List<Integer>> adj;
    static int[] vis;
    static int[] dis;
    static int row;
    static boolean[] chosen;
    static List<Integer> permutation;
    static int k;
    static int count;
    static int[][] arr;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
       int x=sc.nextInt();
       int[] arr= new int[n];
       int[] chek= new int[1000000+1];
       boolean tt=true;
       for(int i=0;i<n;i++){
           arr[i]=sc.nextInt();
           if(chek[arr[i]]!=0){
               tt=false;

           }
           chek[arr[i]]++;
       }
       if(!tt){
           System.out.println(0);
       }else{
           tt=false;
           for(int i=0;i<n;i++){
               int xx=x&arr[i];

               if(chek[xx]!=0 && xx!=arr[i]){
                 //  System.out.println(xx+" "+i);
                   System.out.println(1);

                   tt=true;
                   break;
               }
           }
           if(tt){
              return;
           }else{
               chek=new int[1000000+1];
               for(int i=0;i<n;i++){
                   arr[i]=arr[i]&x;
                   chek[arr[i]]++;

               }
            //  System.out.println(Arrays.toString(arr));
               for(int i=0;i<n;i++){
                   int xx=arr[i];

                   if(chek[xx]>=2 ){
                       //  System.out.println(xx+" "+i);
                       System.out.println(2);
                       return;

                   }
               }

           }
           System.out.println(-1);
       }


    }

    private static long getans1(int[] s, int[] c, int i, int cc, int maxValue) {


        if(cc==1 && i>=0){
            return c[i];
        }else if(cc==0 && i>=0){
            return 0;
        }
        else if(i<0){
            return Integer.MAX_VALUE;
        }
        if(dp[i][cc]!=-1){
            return dp[i][cc];
        }
if(s[i]<maxValue|| maxValue==0){
    return dp[i][cc]= Math.min(getans1(s,c,i-1,cc,maxValue),c[i]+getans1(s,c,i-1,cc-1,s[i]));

}else{
    return dp[i][cc]=getans1(s,c,i-1,cc,maxValue);

}
    }


    private static void swap(int i, int j, int[] arrr) {
        int temp=arrr[i];
        arrr[i]=arrr[j];
        arrr[j]=temp;
    }

    private static long getsum(int[][] h, int i, int p,long[][] dp) {

        if(i>=h[0].length){
            return 0;
        }
        if(dp[i][p]!=-1){
            return   dp[i][p];
        }

        if(p==0){
            long a=getsum(h,i+1,p,dp);
            a=Math.max(a,h[1][i]+getsum(h,i+1,1,dp));
          a=  Math.max(a,h[2][i]+getsum(h,i+1,2,dp));
            return   dp[i][p]=a;
        }else if(p==1){
            long a=getsum(h,i+1,p,dp);
            //a=Math.max(a,h[i][1]+getsum(h,i+1,1));
            a=  Math.max(a,h[2][i]+getsum(h,i+1,2,dp));
            return   dp[i][p]=a;
        }else{
            long  a=getsum(h,i+1,p,dp);
            a=Math.max(a,h[1][i]+getsum(h,i+1,1,dp));
          //  a=  Math.max(a,h[i][2]+getsum(h,i+1,2));
            return   dp[i][p]=a;
        }

    }

    private static int getans(int[] arr, int i) {
        if(i<0)
            return 0;
        else{
            int min=mod;
            for(int j=0;j<arr.length;j++){
                if(arr[j]==1){
                    arr[j]=2;
                    for(int k=0;k<j;k++){
                        if(arr[k]==0){
                            arr[k]=2;
                            min=Math.min(min,Math.abs(j-k)+getans(arr,i-1));
                        }
                    }
                }
            }
            return min;
        }
    }

    private static int ncr(int notsure, int i) {
        int a=1;
        a=(factorail(notsure))/(factorail(notsure-1)*(factorail(i)));
        return a;
    }

    private static int factorail(int notsure) {
        int fac=1;
        for(int i=2;i<=notsure;i++){
            fac=fac+i;
        }
        return fac;

    }

    private static void allPerMutation(int n) {
        if(permutation.size()==n){
            //   System.out.println(permutation);
            long sum=arr[1][permutation.get(0)];
            for(int i=0;i<permutation.size()-1;i++){
                sum+=arr[permutation.get(i)][permutation.get(i+1)];
            }
            sum=sum+arr[permutation.get(n-1)][1];
            if(sum==k){
                count++;
            }

        }else{
            for(int i=2;i<=(n+1);i++){
                if(chosen[i]){
                    continue;
                }
                permutation.add(i);
                chosen[i]=true;
                allPerMutation(n);
                permutation.remove(permutation.size()-1);
                chosen[i]=false;
            }


        }




    }


    public static int Check(int[] arr,int k){
        int sum=0;
        int j=1;
        int total=0;
        for(int i=1;i<arr.length;i++){
            sum+=arr[i];
            if(sum==k){
                total+=(i-j);
                j=i+1;
                sum=0;
            }if(sum>k){
                return arr.length;
            }
        }
        return total;


    }
    public static  char[][] rotateTheBox(char[][] box) {
        Stack<Character> st;
        int m=box.length;
        int n=box[0].length;
        char[][] cc= new char[box[0].length][box.length];
        int k=0;
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                cc[i][j]='.';
            }
        }
        for(int i=m-1;i>=0;i--){

            st=new Stack<>();
            for(int j=0;j<n;j++){
                char c=box[i][j];
                if(c=='#'){
                    st.push(c);
                }else if(c=='*'){
                    cc[j][k]='*';
                    for(int p=j-1;p>=0;p--){
                        if(!st.isEmpty())
                        cc[p][k]=st.pop();
                        else
                            break;
                    }
                    st=new Stack<>();
                }
            }
            if(!st.isEmpty()){
                for(int p=n-1;p>=0;p--){
                    if(!st.isEmpty())
                        cc[p][k]=st.pop();
                    else
                        break;
                }
            }
            k++;


        }
        return cc;


    }







    private static long findans(int[] arr, int i, int s) {
        if (i < 0 && s == 0)
            return 0;
        if (i < 0 && s == 1)
            return 0;
        if (dp[i][s] != -1) {
            return dp[i][s];
        } else {


            if (s == 0)
                return dp[i][s] = Math.max(findans(arr, i - 1, s), -1 * arr[i] + findans(arr, i - 1, 1 - s));
            else
                return dp[i][s] = Math.max(findans(arr, i - 1, s), arr[i] + findans(arr, i - 1, 1 - s));
        }
    }

    public static void dfs(int v, int di) {
        dis[v] = di;
        vis[v] = 1;
        for (int i = 0; i < adj.get(v).size(); i++) {
            int x = adj.get(v).get(i);
            if (vis[x] == 0) {
                dfs(x, di + 1);
            }
        }
    }

    private static boolean isPrime(long a) {
        if (a == 1)
            return true;

        for (int i = 2; i * i <= a; i++) {
            if (a % i == 0)
                return false;

        }
        return true;
    }

    private static int gcd(int aa, int bb) {
        if (bb == 0)
            return aa;
        return gcd(bb, aa % bb);

    }

    private static int lowerBound(int[] ar, int a) {
        int res = 0;
        int s = 1;
        int e = ar.length - 1;
        while (s <= e) {
            int mid = (s) + (e - s) / 2;
            if (ar[mid] <= a) {
                res = mid;
                s = mid + 1;

            } else {
                e = mid - 1;
            }
        }
        return res;
    }

    public static int getXORSum(int[] arr1, int[] arr2) {

        long c = 0;
        int n = arr1.length;
        int m = arr2.length;
        if (n == 1 && m == 1) {
            return arr1[0] & arr2[0];
        }
        int aa = n + m;
        for (int i = 0; i < 32; i++) {

            int z = 0;
            int o = 0;
            int cc = 0;
            for (int a : arr1) {


                int x = (a & (1 << i));
                if (x == 0)
                    z++;
                else
                    o++;


            }
            for (int a : arr2) {
                int x = (a & (1 << i));
                if (x == 0)
                    z++;
                else
                    o++;
            }

            System.out.println(z + " " + o);

            if (z != aa && o != aa) {
                c = c + (1 << i);

            }


        }
        return (int) c;


    }
    static  boolean[] dpbo;
    public static  boolean canReach(String s, int minJump, int maxJump,int i) {
        if(i==0){
            return true;
        }
        if(i<0){
            return false;
        }

        boolean tt=false;
        for(int j=minJump;j<=maxJump;j++){
            if(i-j>=0 && s.charAt(i-j)=='0'){
                tt=(tt|canReach(s,minJump,maxJump,i-j));
            }

        }
        return tt;



    }


}