#include using namespace std; using ll = long long; #define dbl long double #define vec vector #define um unordered_map #define us unordered_set using ull = unsigned long long; using vi = vec; using vl = vector; using vd = vector; using pii = pair; using pll = pair; using pdd = pair; void solve(){ //... } int main(){ cin.sync_with_stdio(false); cin.tie(0); cin.exceptions(ios::failbit); ll n, k; cin >> n >> k; vl cook(n); for (int i = 0; i < n; i++) { cin >> cook[i]; } vi bits(32, 0); int l = 0, r = -1; int orr = 0, cnt = 0; while (r < n) { if (orr <= k) { r++; orr |= cook[r]; int tmp = cook[r]; for (int i = 0; i < 32 && tmp != 0; i++, tmp >>= 1) { if (tmp % 2 == 1) bits[i]++; } } else { int tmp = cook[l]; for (int i = 0; i < 32 && tmp != 0; i++, tmp >>= 1) { if (tmp % 2 == 1) { if (--bits[i] == 0) { orr -= 1 << i; } } } l++; } if (orr == k) { vi newBits = bits; int newOr = orr; int newL = l; while (newOr == k && newL <= r) { //cout << l << " " << r << endl; cnt++; int tmp = cook[newL]; for (int i = 0; i < 32 && tmp != 0; i++, tmp >>= 1) { if (tmp % 2 == 1) { if (--newBits[i] == 0) { newOr -= 1 << i; } } } newL++; } } } cout << cnt << endl; return EXIT_SUCCESS; }