#include using namespace std; const int LOG = 18; int main(){ int N, X; cin >> N >> X; vector A(N); for (int i = 0; i < N; i++){ cin >> A[i]; } vector> sum(LOG, vector(1 << (LOG + 1), 0)); vector cnt(1 << (LOG + 1), 0); for (int i = 0; i < N; i++){ int v = 1; for (int j = 0; j <= LOG; j++){ for (int k = 0; k < LOG; k++){ if (A[i] >> k & 1){ sum[k][v]++; } } cnt[v]++; if (j < LOG){ if (A[i] >> (LOG - 1 - j) & 1){ v = v * 2 + 1; } else { v = v * 2; } } } } long long ans = 0; for (int i = 0; i < N; i++){ int v = 1; vector id; for (int j = LOG - 1; j >= 0; j--){ if (A[i] >> j & 1){ if (X >> j & 1){ id.push_back(v * 2 + 1); v = v * 2; } else { v = v * 2 + 1; } } else { if (X >> j & 1){ id.push_back(v * 2); v = v * 2 + 1; } else { v = v * 2; } } } for (int x : id){ for (int j = 0; j < LOG; j++){ if (A[i] >> j & 1){ ans += cnt[x] << j; } else { ans += sum[j][x] << j; } } } } for (int i = 0; i < N; i++){ ans -= A[i]; } cout << ans / 2 << endl; }