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 java.io.BufferedReader;
// import java.io.FileInputStream;
// import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.util.Arrays.copyOf;
import static java.util.Arrays.fill;
import static java.util.Arrays.sort;
import static java.util.Collections.sort;

public class Main {
    FastScanner in;
    PrintWriter out;

    private void solve() throws IOException {
        solveB();
        // solveC();
        // solveD();
        // solveE();
    }

    private void solveB() throws IOException {
        int n = in.nextInt(), x = in.nextInt(), ans = 3;
        int[][] cnt = new int[2][100001];
        for (int i = 0, ai; i < n; i++) {
            ai = in.nextInt();
            cnt[0][ai]++;
            cnt[1][ai & x]++;
        }

        for (int ai = 0; ai < 100001; ai++) {
            if (cnt[0][ai] > 0) {
                if (cnt[0][ai] > 1)
                    ans = min(ans, 0);
                else if ((ai & x) != ai && cnt[0][ai & x] > 0)
                    ans = min(ans, 1);
                else if (cnt[1][ai & x] > 1)
                    ans = min(ans, 2);
            }
        }

        out.println(ans == 3 ? -1 : ans);
    }

    private void solveC() throws IOException {
        int n = in.nextInt();
        long[] a = new long[n * 2];
        for (int i = 0; i < n * 2; i++)
            a[i] = in.nextLong();

        shuffle(a);
        sort(a);
        long min = (a[n - 1] - a[0]) * (a[2 * n - 1] - a[n]);

        for (int i = 1; i < n; i++)
            min = min(min, (a[n - 1 + i] - a[i]) * (a[2 * n - 1] - a[0]));

        out.println(min);
    }

    void shuffle(long[] a) {
        long b;
        Random r = new Random();
        for (int i = a.length - 1, j; i > 0; i--) {
            j = r.nextInt(i + 1);
            b = a[j];
            a[j] = a[i];
            a[i] = b;
        }
    }

    ArrayList<Integer>[] row, col;
    boolean[] usedR, usedC;

    void dfs(int i, int j) {
        usedR[i] = true;
        usedC[j] = true;
        for (int jj : row[i])
            if (!usedC[jj])
                dfs(i, jj);
        for (int ii : col[j])
            if (!usedR[ii])
                dfs(ii, j);
    }

    private void solveD() throws IOException {
        int n = in.nextInt(), m = in.nextInt();
        int q = in.nextInt();

        if (q == 0) {
            out.println(n + m - 1);
            return;
        }

        int[] qr = new int[q], qc = new int[q];

        row = new ArrayList[n];
        for (int i = 0; i < n; i++)
            row[i] = new ArrayList<>();

        col = new ArrayList[m];
        for (int i = 0; i < m; i++)
            col[i] = new ArrayList<>();

        for (int i = 0; i < q; i++) {
            qr[i] = in.nextInt() - 1;
            qc[i] = in.nextInt() - 1;
            row[qr[i]].add(qc[i]);
            col[qc[i]].add(qr[i]);
        }

        usedR = new boolean[n];
        usedC = new boolean[m];

        int cnt = -1;
        for (int i = 0; i < n; i++) {
            if (!usedR[i]) {
                cnt++;
                if (row[i].size() > 0)
                    dfs(i, row[i].get(0));
                else
                    dfs(i, qc[0]);

                out.println("row " + i);
                out.println(Arrays.toString(usedR));
                out.println(Arrays.toString(usedC));
            }
        }
        for (int i = 0; i < m; i++) {
            if (!usedC[i]) {
                cnt++;
                if (col[i].size() > 0)
                    dfs(col[i].get(0), i);
                else
                    dfs(qr[0], i);

                out.println("col " + i);
                out.println(Arrays.toString(usedR));
                out.println(Arrays.toString(usedC));
            }
        }
        out.println(cnt);
    }

    private void solveE() throws IOException {
        int n = in.nextInt(), k = (n + 1) / 2 + 1;
        int[] a = new int[n + 4];
        for (int i = 0; i < n; i++)
            a[i + 3] = in.nextInt();

        long[][][] ans = new long[2][n + 4][k];
        for (int i = 0; i < 2; i++)
            for (int j = 0; j < n + 4; j++)
                for (int l = 0; l < k; l++)
                    ans[i][j][l] = l == 0 ? 0 : Long.MAX_VALUE >> 1;

        for (int i = 4; i < n + 4; i++) {
            ans[0][i][1] = (a[i] - min(a[i], a[i - 1] - 1)) + (a[i - 2] - min(a[i - 2], a[i - 1] - 1));
            ans[1][i][1] = min(ans[0][i - 1][1], ans[1][i - 1][1]);
            for (int j = 2; j < k; j++) {
                ans[0][i][j] = (a[i] - min(a[i], a[i - 1] - 1)) + (a[i - 2] - min(a[i - 2], a[i - 1] - 1))
                        + min(ans[0][i - 2][j - 1] - (min(a[i - 2], a[i - 1] - 1) < a[i - 3] ? a[i - 2] - min(a[i - 2], a[i - 3] - 1) : 0),
                        ans[1][i - 2][j - 1]);
                ans[1][i][j] = min(ans[0][i - 1][j], ans[1][i - 1][j]);
            }
        }

        for (int i = 1; i < k; i++)
            out.print(min(ans[0][n + 3][i], ans[1][n + 3][i]) + " ");
    }

    class FastScanner {
        StringTokenizer st;
        BufferedReader br;

        FastScanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        boolean hasNext() throws IOException {
            return br.ready() || (st != null && st.hasMoreTokens());
        }

        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        double nextDouble() throws IOException {
            return Double.parseDouble(next().replace(',', '.'));
        }

        String nextLine() throws IOException {
            return br.readLine();
        }

        boolean hasNextLine() throws IOException {
            return br.ready();
        }
    }

    private void run() throws IOException {
        in = new FastScanner(System.in); // new FastScanner(new FileInputStream(".in"));
        out = new PrintWriter(System.out); // new PrintWriter(new FileOutputStream(".out"));

        solve();

        out.flush();
        out.close();
    }

    public static void main(String[] args) throws IOException {
        new Main().run();
    }
}