#include #define REP(i, n) for (int i = 0; (i) < (int)(n); ++(i)) #define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++(i)) #define REP_R(i, n) for (int i = (int)(n)-1; (i) >= 0; --(i)) #define REP3R(i, m, n) for (int i = (int)(n)-1; (i) >= (int)(m); --(i)) #define ALL(x) ::std::begin(x), ::std::end(x) using namespace std; int64_t solve(int n, int64_t t, const vector& a) { map cur; cur[t] = 0; REP (i, n) { map prv; cur.swap(prv); for (auto [x, prv_x] : prv) { cur[x & a[i]] = max(cur[x & a[i]], prv_x + abs((x & a[i]) - x)); cur[x | a[i]] = max(cur[x | a[i]], prv_x + abs((x | a[i]) - x)); } } int64_t ans = 0; for (auto [x, cur_x] : cur) { ans = max(ans, cur_x); } return ans; } // generated by online-judge-template-generator v4.7.1 (https://github.com/online-judge-tools/template-generator) int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); constexpr char endl = '\n'; int64_t N; int64_t T; cin >> N; vector A(N); cin >> T; REP (i, N) { cin >> A[i]; } auto ans = solve(N, T, A); cout << ans << endl; return 0; }