//#define _GLIBCXX_DEBUG #include #define rep(i, n) for(int i=0; i; using vs = vector; using vi = vector; using vvi = vector; template using PQ = priority_queue; template using PQG = priority_queue, greater >; const int INF = 0xccccccc; const ll LINF = 0xcccccccccccccccLL; template inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);} template inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);} template istream &operator>>(istream &is, pair &p) { return is >> p.first >> p.second;} template ostream &operator<<(ostream &os, const pair &p) { return os << p.first << ' ' << p.second;} struct SegTree { struct node { int sum; vector cc; node():sum(0), cc(18) {} int &operator[] (int i) {return cc[i];} }; using T = node; int n, _n; const T ex; vector dat; SegTree(T ex_ = node()):ex(ex_), n(1<<18) { dat.assign((n<<1)-1, ex); } inline int chld(int k) {return (k<<1)+1;} inline int chrd(int k) {return (k<<1)+2;} inline ll query(int a, int x) {return query(a, x, 17, 0, 0, n);} ll query(int a, int x, int z, int k, int l, int r) { if(l > x) return 0; if(r <= x) { ll res = 0; rep(i, 18) { if(a>>i&1) res += dat[k].sum * (1<>z&1)?chld(k):chrd(k), l, (l+r)>>1); ll vr = query(a, x, z-1, (~a>>z&1)?chrd(k):chld(k), (l+r)>>1, r); return vl + vr; } void update(int a) {update(a, 0, 0, n);} void update(int a,int k, int l, int r) { if(r-l == 1) { dat[k].sum++; rep(j, 18) if(a>>j&1) { dat[k][j]++; } } else { if(a < ((l+r)>>1)) update(a, chld(k), l, (l+r)>>1); else update(a, chrd(k), (l+r)>>1, r); T &c = dat[k]; c.sum++; rep(i, 18) if(a>>i&1) c[i]++; } } const T &operator[](int idx) const {return dat[idx+n-1];} T &operator[](int idx) {return dat[idx+n-1];} }; #define N 200100 //head int n, x; SegTree seg; ll ans; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> x; rep(i, n) { int a; cin >> a; ans += seg.query(a, x); seg.update(a); } cout << ans << endl; }