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.
//package Mura;
/*****   BY MURAD   ******/
/*Everyone has a different way of thinking, so God Created us*/
/*Hope You Respect My Way..,Thank You*/
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class Code {
    public static int max(int a, int b)
    {
        return (a > b)? a : b;
    }
    public static int GetKthItem(int[] arr1, int[] arr2,int low1 ,int hig1, int low2,int hig2, int k)
    {
        if(hig1<low1)
        {
            return arr2[hig2-k+1];
        }
        if(hig2<low2)
        {
            return arr1[hig1-k+1];
        }
        if(hig1==low1)
        {
            if(k==1)
            {
                return Math.max(arr1[low1],arr2[hig2]);
            }
            else
                return GetKthItem(arr1,arr2,low1,hig1-1,low2,hig2,k-1);
        }
        if(hig2==low2)
        {
            if(k==1)
                return Math.max(arr2[low2],arr1[hig1]);
            else
                return GetKthItem(arr1,arr2,low1,hig1,low2,hig2-1,k-1);
        }
        if(k==1)
            return Math.max(arr1[hig1],arr2[hig2]);
        int m1 = (low1 + hig1) / 2;
        int m2 = (low2 + hig2) / 2;
        if (arr1[m1] <= arr2[m2])
        {
            int check=k-(hig2-m2);
            if(check>=1) {
                return GetKthItem(arr1, arr2, low1, hig1, low2, m2 , k - (hig2 - m2));
            }
            else
                return arr2[hig2-k+1];
        }
        else {
            int check=k-(hig1-m1);
            if(check>=1) {
                return GetKthItem(arr1, arr2, low1, m1 , low2, hig2, k - (hig1 - m1));
            }
            else
                return arr1[hig1-k+1];
        }
    }
    static class DPS {
        void print(int a[][])
        {
            for(int i=0;i<a.length;i++)
            {
                for(int j=0;j<a[0].length;j++)
                {
                    System.out.print(a[i][j]+" ");
                }
                System.out.println();
            }
        }
        int lcs( char[] X, char[] Y, int m, int n )
        {
            int L[][] = new int[m+1][n+1];
            for (int i=0; i<=m; i++)
            {
                for (int j=0; j<=n; j++)
                {
                    if (i == 0 || j == 0) {
                        L[i][j] = 0;
                        continue;
                    }
                    else if (X[i-1] == Y[j-1])
                        L[i][j] = L[i-1][j-1] + 1;
                    else
                        L[i][j] = max(L[i-1][j], L[i][j-1]);
                }
            }
            return L[m][n];
        }
        String LongestSubPlindrome(String s) {
            int len = s.length();
            if (s == null || len < 2)
                return s;
            boolean table[][] = new boolean[len][len];
            int left = 0, right = 0;
            for (int i = 1; i < len; i++) {
                for (int j = 0; j < i; j++) {
                    boolean isplindrome = table[i - 1][j + 1] || i - j <= 2;
                    if (s.charAt(i) == s.charAt(j) && isplindrome) {
                        table[i][j] = true;
                        if (i - j > right - left) {
                            left = j;
                            right = i;
                        }
                    }
                }
            }
            return s.substring(left, right + 1);
        }
        int knp(int []wt,int []val,int n,int W)
        {
            int i, w;
            int K[][] = new int[n+1][W+1];

            // Build table K[][] in bottom up manner
            for (i = 0; i <= n; i++)
            {
                for (w = 0; w <= W; w++)
                {
                    if (i==0 || w==0)
                        K[i][w] = 0;
                    else if (wt[i-1] <= w)
                        K[i][w] = Math.max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]);
                    else
                        K[i][w] = K[i-1][w];
                }
            }

            return K[n][W];
        }
         int cutRod(int price[],int n)
        {
            int val[] = new int[n+1];
            val[0] = 0;
            // Build the table val[] in bottom up manner and return
            // the last entry from the table
            for (int i = 1; i<=n; i++)
            {
                int max_val = Integer.MIN_VALUE;
                for (int j = 0; j < i; j++)
                    max_val = Math.max(max_val,
                            price[j] + val[i-j-1]);
                val[i] = max_val;
            }
            return val[n];
        }
        int LIS(int []a,int n)
        {
            int dp[]=new int[n+1];
            dp[0]=1;
            for(int i=1;i<n;i++)
            {
                int maxval=Integer.MIN_VALUE;
                for(int j=0;j<i;j++)
                {
                    if(a[i]>a[j])
                    {
                        dp[i]=dp[i-1]+1;
                    }
                    else
                    {
                        dp[i]=dp[i-1];
                    }
                }
            }
            return dp[n-1];
        }
        int edit_dist(char[]x,char[]y,int xl,int yl)
        {
            int dp[][]=new int[xl+1][yl+1];
            for(int i=0;i<=xl;i++)
            {
                for(int j=0;j<=yl;j++)
                {
                    if (i==0) {
                        dp[i][j] = j;
                        continue;
                    }
                    if (j==0) {
                        dp[i][j] = i;
                        continue;
                    }
                    if(x[i-1]==y[j-1])
                    {
                        dp[i][j]=dp[i-1][j-1];
                    }
                    else
                        dp[i][j]=1+Math.min(dp[i][j-1],Math.min(dp[i-1][j],dp[i-1][j-1]));
                }
            }
            return dp[xl][yl];
        }
    }
    static class DC{
         void insertion_sort(int []a,int left,int right)
        {
            int n = left + right;
            for (int i = left + 1; i <= right; ++i)
            {
                int key = a[i];
                int j = i - 1;
                while (j >= 0 && a[j] > key)
                {
                    a[j + 1] = a[j];
                    j = j - 1;
                }
                a[j + 1] = key;
            }
        }

        void merg(int []arr,int low,int mid,int hig)
        {
            int nleft=mid-low+1;
            int nright=hig-mid;
            int left[]=new int[nleft];
            int []right=new int[nright];
            for(int i=0;i<nleft;i++)
                left[i]=arr[i+low];
            for(int j=0;j<nright;j++)
                right[j]=arr[j+mid+1];
            int i=0,j=0;
            int k=low;
            while (i<nleft&&j<nright)
            {
                if(left[i]<=right[j])
                {
                    arr[k]=left[i];
                    i++;
                }
                else
                {
                    arr[k]=right[j];
                    j++;
                }
                k++;
            }
            while(i<nleft)
            {
                arr[k]=left[i];
                i++;
                k++;
            }
            while(j<nright)
            {
                arr[k]=right[j];
                j++;
                k++;
            }
        }
        void sort_merg(int []a,int low,int hig){
            if(low<hig)
            {
                int mid=(low+hig)/2;
                sort_merg(a,low,mid);
                sort_merg(a,mid+1,hig);
                merg(a,low,mid,hig);
            }
        }
        int findKthLargest(int[] nums, int k) {
            int start = 0, end = nums.length - 1, index = nums.length - k;
            while (start < end) {
                int pivot = partion(nums, start, end);
                if (pivot < index) start = pivot + 1;
                else if (pivot > index) end = pivot - 1;
                else return nums[pivot];
            }
            return nums[start];
        }
        int partion(int[] nums, int start, int end) {
            int pivot = start, temp;
            while (start <= end) {
                while (start <= end && nums[start] <= nums[pivot]) {
                    start++;
                }
                while (start <= end && nums[end] > nums[pivot]) {
                    end--;
                }
                if (start > end) break;
                temp = nums[start];
                nums[start] = nums[end];
                nums[end] = temp;
            }
            temp = nums[end];
            nums[end] = nums[pivot];
            nums[pivot] = temp;
            return end;
        }
        int kth_smallest(int a[],int low,int hig,int k)
        {
            if(k<=low+hig)
            {
                int pos=partition_qs(a,low,hig);
                if(pos==k)
                    return a[pos];
                if(pos>k)
                    return kth_smallest(a,low,pos-1,k);
                return kth_smallest(a,pos+1,hig,k);
            }
            return 0;
        }
        int partition_qs(int a[],int low,int hig){
            int i=low-1;
            int j=low;
            int piv=a[hig];
            for(j=low;j<hig;j++)
            {
                if(a[j]<=piv)
                {
                    i++;
                    int temp=a[i];
                    a[i]=a[j];
                    a[j]=temp;
                }
            }
            int temp=a[i+1];
            a[i+1]=piv;
            a[hig]=temp;
            return i+1;
        }
        void sort(int a[],int low,int hig)
        {
            if(low<hig)
            {
                int p1=partition_qs(a,low,hig);
                sort(a,low,p1-1);
                sort(a,p1+1,hig);
            }
        }
    }
    public static long mod=998244353;
    public static boolean isPowerOfTwo(int n)
    {
        if (n == 0)
            return false;
        while (n != 1)
        {
            if (n % 2 != 0)
                return false;
            n = n / 2;
        }
        return true;
    }
    public static long GCD(long x,long y){
        if(y==0)
            return x;
        else
            return GCD(y,x%y);
    }
    static class Graph {
        private int v;
        private ArrayList<Integer> adj[];
        Graph(int vv) {
            v = vv;
            adj = new ArrayList[v];
            for (int i = 0; i < v; ++i) {
                adj[i] = new ArrayList<>();
            }
        }
        void addEdge(int v, int w) {
            adj[v].add(w);
            adj[w].add(v);
        }
    }
    public static void main(String[] args)throws IOException {
        Scanner inp = new Scanner(System.in);
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int n=Integer.parseInt(st.nextToken()),x=Integer.parseInt(st.nextToken());
        int a[]=new int[n];
        HashSet<Integer>set=new HashSet<>();
        HashSet<Integer>set2=new HashSet<>();
        st=new StringTokenizer(br.readLine());
        int le=set.size(),ans=-1,j=0;
        for(int i=0;i<n;i++)
        {
            a[i]=Integer.parseInt(st.nextToken());
            set.add(a[i]);
            if(set.size()>le)
            {
                le=set.size();
            }
            else
            {
                System.out.println(0);
                return;
            }
        }
        for(int i=0;i<n;i++)
        {
            int res = a[i] & x;
            set2.add(res);
            if (res!=a[i]&&set.contains(res)) {
                System.out.println(1);
                return;
            }
        }
        System.out.println(set2.size()==n?-1:2);
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
    }
    static class Pair implements Comparable<Pair> {
        int value, idx;
        Pair(int v, int i)
        {
            value = v;
            idx = i;
        }
        @Override
        public int compareTo(Pair p) {
            return value - p.value;
        }
    }
    public static int[] bctsort(int[] array, int bucketCount) {
        if (bucketCount <= 0) throw new IllegalArgumentException("Invalid bucket count");
        if (array.length <= 1) return array;
        int high = array[0];
        int low = array[0];
        for (int i = 1; i < array.length; i++) {
            if (array[i] > high) high = array[i];

            if (array[i] < low) low = array[i];
        }
        double interval = ((double)(high - low + 1))/bucketCount;
        ArrayList<Integer> buckets[] = new ArrayList[bucketCount];
        for (int i = 0; i < bucketCount; i++) {

            buckets[i] = new ArrayList();

        }
        for (int i = 0; i < array.length; i++) {

            buckets[(int)((array[i] - low)/interval)].add(array[i]);
        }
        int pointer = 0;

        for (int i = 0; i < buckets.length; i++) {

            Collections.sort(buckets[i]);

            for (int j = 0; j < buckets[i].size(); j++) {

                array[pointer] = buckets[i].get(j);

                pointer++;

            }
        }
        return array;
    }
    /*
      int maxValueInMap=(Collections.max(mp.values()));  // This will return max value in the Hashmap
        for (Map.Entry<String, Integer> entry : mp.entrySet()) {  // Itrate through hashmap
            if (entry.getValue()==maxValueInMap) {
                System.out.println(entry.getKey());
                break;
            }
        }
        Relatively Prime :- if diffrence between two number is equal to 1
    */
}