#include using namespace std; #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; typedef vector> vpii; template using vec = vector; template using uset = unordered_set; template using umap = unordered_map; template struct ROQ { // Range Or Query vector> jmp; ROQ(const vector &V) : jmp(1, V) { for (int pw = 1, k = 1; pw * 2 <= sz(V); pw *= 2, ++k) { jmp.emplace_back(sz(V) - pw * 2 + 1); rep(j, 0, sz(jmp[k])) jmp[k][j] = jmp[k - 1][j] | jmp[k - 1][j + pw]; } } T query(int a, int b) { assert(a < b); int dep = 31 - __builtin_clz(b - a); return jmp[dep][a] | jmp[dep][b - (1 << dep)]; } }; int lowerBound(int lo, int hi, int from, ROQ & roq, int value) { while (lo < hi) { int mid = lo + (hi - lo) / 2; if (roq.query(from, mid + 1) < value) { lo = mid + 1; } else hi = mid; } return lo; } int upperBound(int lo, int hi, int from, ROQ & roq, int value) { while (lo < hi) { int mid = lo + (hi - lo) / 2; if (!(value < roq.query(from, mid + 1))) { lo = mid + 1; } else hi = mid; } return lo; } void solve () { int n, k; cin >> n >> k; vi v(n); for (auto & el : v) cin >> el; ROQ roq(v); ll sum = 0; rep(i, 0, n) { auto lo = lowerBound(i, n, i, roq, k); if (lo == n || roq.query(i, lo + 1) != k) continue; auto hi = upperBound(i, n, i, roq, k); sum += hi - lo; } cout << sum << endl; } int main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); ll T = 1; //cin >> T; rep(i, 0, T) solve(); return 0; }