#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))

#define rep(i,n) for(int i=0; i<(int)(n); i++)

const int mod = 1000000007;

vector<pair<int, int>> st[30];
int cnts[200005];

struct mint {
    ll x;
    mint(ll x=0):x(x%mod){}

    mint& operator+=(const mint a) {
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint& operator-=(const mint a) {
        if((x -= mod-a.x) >= mod) x -= mod;
        return *this;
    }

    mint& operator*=(const mint a) {
        x = (x * a.x) % mod;
        return *this;
    }

    mint& operator/=(const mint a) {
        *this *= a.inv();
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }

    mint pow(ll n) const {
        mint a(*this);
        mint res = 1;
        while (n > 0) {
            if (n & 1) res *= a;
            a *= a;
            n >>= 1;
        }
        return res;
    }

    mint inv() const {
        return pow(mod - 2);
    }
};

long cnt0[55];
long cnt1[55];

ll dp[2][55];

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  long n, k;
  cin >> n >> k;

  vector<long> a(n);
  fillLong(a, n);

  rep(i, n) {
    rep(j, 50) {
      if (a[i] & (1LL<<j)) {
        cnt1[j]++;
      } else {
        cnt0[j]++;
      }
    }
  }


  for(int i = 45; i>= 0; i--) {
    if (k & (1L<<i)) {
      long d1 = dp[0][i+1] + cnt0[i] * (1L<<i);
      long d2 = dp[0][i+1] + cnt1[i] * (1L<<i);
      long d3 = dp[1][i+1] + cnt1[i] * (1L<<i);
      if (dp[0][i+1]) {
        dp[0][i] = max(max(d1, d2), d3);
      } else {
        dp[0][i] = max(d2, d3);
      }
      dp[1][i] = dp[1][i+1] + cnt0[i] * (1L<<i);
    } else {
      if (dp[0][i+1]) {
        dp[0][i] = dp[0][i+1] + max(cnt0[i], cnt1[i]) * (1L<<i);
      }
      dp[1][i] = dp[1][i+1] + cnt1[i] * (1L<<i);
    }
  }

  cout << max(dp[0][0], dp[1][0]) << endl;
}


Measured memory_bytes: 1400