#include using namespace std; struct BinaryTrie{ int nth_bit(int64_t x, int n){ return (x>>n) & 1; } struct Node{ Node* ch[2]; vector> num; Node(){ ch[0] = ch[1] = nullptr; num = vector>(18, vector(2)); } }; int B; Node* root; BinaryTrie(int B=0){ if(B) initialize(B); } void initialize(int inB){ B = inB; root = new Node(); } void insert(Node* node, int x, int depth){ for(int k=0; k<18; k++) node->num[k][nth_bit(x, k)]++; if(depth < B){ int nextdepth = depth + 1; int nextbit = nth_bit(x, B - nextdepth); if(!node->ch[nextbit]) node->ch[nextbit] = new Node(); insert(node->ch[nextbit], x, nextdepth); } } void insert(int x){ insert(root, x, 0); } void calc(Node* node, int x, int now, int K, int X, int64_t& ans){ if(!node) return; int mn = now, mx = now + (1LL<= X) return; if(mx < X){ for(int k=0; k<18; k++) for(int t=0; t<2; t++) ans += node->num[k][t] * (1LL< 0) for(int t=0; t<2; t++) calc(node->ch[t], x, now + (1LL<<(K-1)) * (nth_bit(x, K-1) ^ t), K-1, X, ans); } void calc(int x, int X, int64_t& ans){ return calc(root, x, 0, B, X, ans); } }; int main(){ int N, X; cin >> N >> X; BinaryTrie bt(18); vector A(N); for(int i=0; i> A[i]; bt.insert(A[i]); } int64_t ans = 0; for(int a : A){ ans -= a; bt.calc(a, X, ans); } ans /= 2; cout << ans << endl; }