#include <bits/stdc++.h>   using namespace std;   int a[100005], n, x, minn = 3;   bool m1[100005], m2[100005];   int read() {     int w = 0, f = 1;     char c = getchar();     while (c >  9  || c <  0 ) {       if (c ==  - ) f = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       w = (w << 3) + (w << 1) + (c ^ 48);       c = getchar();     }     return w * f;   }   int main() {     n = read(), x = read();     for (int i = 1; i <= n; i++) {       a[i] = read();     }     for (int i = 1; i <= n; i++) {       if (m1[a[i]]) minn = min(0, minn);       if (m2[a[i]]) minn = min(1, minn);       if (m1[a[i] & x]) minn = min(1, minn);       if (m2[a[i] & x]) minn = min(2, minn);       m1[a[i]] = 1, m2[a[i] & x] = 1;     }     if (minn == 3)       puts( -1 );     else       printf( %d n , minn);     return 0;   }   