#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define pdump(p) cout<<" "<<#p<<"=("<<p.fst<<","<<p.snd<<")"
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std; using lint = long long; using ld = long double;
using pii = pair<int, int>; using pll = pair<lint, lint>;

int main(void) {
    lint n, ktag;
    cin >> n >> ktag;
    vector<lint> atag(n);
    repeat (i, n) {lint t; cin >> t; atag[i] = (t);}
    const vector<lint> adec = atag;
    const lint kdec = (ktag);
    const lint digit50 = 50LL;
    
    if (kdec == 0) {
        lint sum = 0;
        repeat (i, n) sum += adec[i];
        cout << sum << endl;
        return 0;
    }
    
    auto tobinary = [](lint n) -> vector<lint> {
        vector<lint> ret;
        repeat (i, digit50 + 1) {
            lint m = n;
            int t;
            t = (m >> (digit50-i)) % 2LL;
            ret.push_back(t);
        }
        return ret;
    };
    
    vector<lint> k = tobinary(kdec);
    vector<vector<lint>> a(n);
    repeat (i, n) a[i] = tobinary(adec[i]);
    
    vector<lint> opt(digit50+1);
    repeat_from_to (i, 0, digit50) {
        lint zero = 0;
        lint one = 0;
        repeat (j, n) {
            if (a[j][i] == 0) ++zero;
            else ++one;
        }
        if (zero > one) opt[i] = 1;
        else opt[i] = 0;
    }
    
    //cout << "  k="; for (auto e: k) cout << e; el;
    //cout << "opt="; for (auto e: opt) cout << e; el;
    
    auto calc = [](vector<lint> adec, vector<lint> t) -> lint {
        lint tdec = 0;
        repeat_from_to (i, 0, digit50) {
            tdec += (t[i] * (1LL << (digit50 - i)));
        }
        lint ret = 0;
        repeat (i, adec.size()) {
            ret += (adec[i] ^ tdec);
        }
        //dump(tdec); dump(ret); el;
        return ret;
    };
    
    lint ans = 0;
    repeat_from_to (d, 0, digit50) {
        if (k[d] > 0) {
            // d 以降フリー
            vector<lint> t(digit50+1);
            repeat_from_to (i, 0, digit50) {
                if (i < d) {
                    t[i] = k[i];
                }
                else if (i == d) {
                    t[i] = 0;
                }
                else {
                    t[i] = opt[i];
                }
            }
            //dump(d); vdump(t); el;
            //cout << "  t="; for (auto e: t) cout << e; dump(d); el;
            ans = max(ans, calc(adec, t));
        }
    }
    
    ans = max(ans, calc(adec, k));
    cout << ans << endl;
    
    /*
    lint ans2 = 0;
    repeat_from_to (i, 0, kdec) {
        lint sum2 = 0;
        repeat (j, adec.size()) {
            sum2 += (adec[j] ^ i);
        }
        ans2 = max(ans2, sum2);
    }
    cout << ans2 << endl;
    */
}

Measured memory_bytes: 56560