#include using namespace std; #define int long long #define rep(i, a, b) for (int i=a;i<(b); ++i) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() typedef long long ll; typedef pair pii; typedef vector vi; typedef vector vvi; auto MMM = numeric_limits::max(); signed main() { cin.tie(0)->sync_with_stdio(0); int N, K; cin >> N >> K; vi C(N); for(int i = 0; i < N; i++) cin >> C[i]; vi powers(32); for(int i =0; i < 32; i++) powers[i] = 1 << i; map look_f; set pos, neg; for(auto power: powers) { look_f[power] = vi(N); if(K & power) pos.insert(power); else neg.insert(power); } map last_seen; for(auto power: powers) last_seen[power] = N; //pos.contains(power) ? MMM : MMM; for(int idx = N-1; idx >= 0; idx--) { auto curr = C[idx]; for(auto power: powers) { if(curr & power) last_seen[power] = idx; look_f[power][idx] = last_seen[power]; } } int res = 0; for(int start = 0; start < N; start++) { auto min_end = start; for(auto p: pos) { min_end = max(min_end, look_f[p][start]); } auto max_end = N; for(auto n : neg) { max_end = min(max_end, look_f[n][start]); } if(min_end < max_end) res += max_end - min_end; } cout << res << endl; }