#include<bits/stdc++.h> usingnamespacestd; constint N = 6e5 + 5; typedeflonglong ll; int n, m, idx, cnt[N], trie[N][2];
voidinsert(int x){ int p = 0, y; for (int i = 31; ~i; i--) { y = x >> i & 1; int &s = trie[p][y]; if (!s) s = ++idx; p = s; cnt[p]++; } }
intquery(int x){ int p = 0, p1, sum = 0; for (int i = 31; ~i; i--) { int y = x >> i & 1; int z = m >> i & 1; if (y == 1 && z == 1) { p = trie[p][0]; } elseif (y == 0 && z == 1) { p = trie[p][1]; } elseif (y == 1 && z == 0) { p1 = trie[p][0]; p = trie[p][1]; if (p1) sum += cnt[p1]; } elseif (y == 0 && z == 0) { p1 = trie[p][1]; p = trie[p][0]; if (p1) sum += cnt[p1]; } if (!p) break; } return sum; }
intmain(){ longlong res = 0; scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) { int x; scanf("%d", &x); res += query(x); insert(x); } printf("%lld\n", res); return0; }