#include using namespace std; #define int long long int n, k; int a[1010101]; int rmq[25][1010101]; int L[1010101]; int gt(int l, int r) { int x = L[r - l + 1]; // cout << " <<< < " << l << " " << r << " " << x << endl; return (rmq[x][l] | rmq[x][r - (1 << x) + 1]); } int Upper(int i) { int l = i - 1, r = n + 1; while (l + 1 < r) { int mid = (l + r) / 2; if (gt(i, mid) > k) r = mid; else l = mid; } return l; } int Lower(int i) { int l = i - 1, r = n + 1; while (l + 1 < r) { int mid = (l + r) / 2; if (gt(i, mid) >= k) r = mid; else l = mid; } return r; } int32_t main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> k; for (int i = 1; i <= n; i++) cin >> a[i]; L[1] = 0; for (int i = 2; i <= n; i++) { L[i] = L[i / 2] + 1; // cout << "?? " << i << " -- " << L[i] << endl; } for (int i = 1; i <= n; i++) { rmq[0][i] = a[i]; } for (int i = 1; i <= 22; i++) { for (int j = 1; j + (1 << i) - 1 <= n; j++) { rmq[i][j] = (rmq[i - 1][j] | rmq[i - 1][j + (1 << (i - 1))]); } } // for (int i = 1; i <= n; i++) // cout << gt(1, i) << endl; int ans = 0; for (int i = 1; i <= n; i++) { int hvU = Upper(i), hvL = Lower(i); // cout << i << " -- " << hvL << " " << hvU << endl; if (hvU < i || hvU > n || hvL < i || hvL > n) continue; ans += (hvU - hvL + 1); } cout << ans << '\n'; return 0; }