#include using namespace std; typedef unsigned long long ull; typedef long long ll; struct AndPair { ull val; ll cnt; }; void submit(){ freopen( "note2.in", "r", stdin ); freopen( "note2.out", "w", stdout ); } int main(){ submit(); int n; ull M; cin >> n >> M; vector a(n); for (int i = 0; i < n; i++){ cin >> a[i]; } ll ans = 0; // dp will store the distinct AND values for subarrays ending at the previous index. // Since there are very few distinct values, we use a fixed-size array. AndPair dp[70]; int dp_size = 0; for (int i = 0; i < n; i++){ AndPair newdp[70]; int newdp_size = 0; // Start a new subarray [i, i] with a[i]. newdp[0].val = a[i]; newdp[0].cnt = 1; newdp_size = 1; // Extend every subarray ending at i-1 by including a[i]. for (int j = 0; j < dp_size; j++){ ull newVal = dp[j].val & a[i]; // Because AND is monotonic (only drops bits), many extended subarrays yield the same result. if(newdp[newdp_size - 1].val == newVal) { newdp[newdp_size - 1].cnt += dp[j].cnt; } else { newdp[newdp_size].val = newVal; newdp[newdp_size].cnt = dp[j].cnt; newdp_size++; } } // For every distinct AND value in newdp, add the counts if the value is at least M. for (int j = 0; j < newdp_size; j++){ if(newdp[j].val >= M) ans += newdp[j].cnt; } // Copy newdp into dp for the next iteration. dp_size = newdp_size; for (int j = 0; j < dp_size; j++){ dp[j] = newdp[j]; } } cout << ans << "\n"; return 0; }