#include using namespace std; typedef long long ll; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); ifstream fin("note2.in"); ofstream fout("note2.out"); int N; ll M; fin >> N >> M; vector a(N); for (int i = 0; i < N; i++){ fin >> a[i]; } // Special-case: if M == 0, every subarray qualifies. if(M == 0){ ll total = (ll)N * (N + 1) / 2; fout << total; return 0; } // dp will hold pairs (value, count) for distinct cumulative AND values // of subarrays ending at the previous index. vector> dp; ll answer = 0; for (int i = 0; i < N; i++){ vector> newdp; // The subarray that starts and ends at i newdp.push_back({a[i], 1}); // Extend each subarray ending at i-1 by including a[i]. for (auto &p : dp) { ll new_val = p.first & a[i]; // If the last pair in newdp has the same value, merge the count. if (!newdp.empty() && newdp.back().first == new_val) newdp.back().second += p.second; else newdp.push_back({new_val, p.second}); } // Count subarrays ending at i whose AND >= M. for (auto &p : newdp) { if(p.first >= M) answer += p.second; } dp = move(newdp); } fout << answer; return 0; }