#include using namespace std; using ll = long long; using ull = unsigned long long; int nb[400001][31]; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, k; cin >> n >> k; vector as(n); for(int i = 0; i < n; ++i) { cin >> as[i]; } for(int j = 0; j < 31; ++j) { nb[n][j] = n; } for(int i = n-1; i >= 0; --i) { for(int j = 0; j < 31; ++j) { if(as[i] & (1 << j)) { nb[i][j] = i; } else { nb[i][j] = nb[i+1][j]; } } } ll res = 0; for(int i = 0; i < n; ++i) { int a = 0; vector ais(31); for(int j = 0; j < 31; ++j) { ais[j] = nb[i][j]; } sort(begin(ais), end(ais)); int li = i; for(int j = 0; j < 31; ++j) { if(a == k) { res += ais[j] - li; } if(ais[j] == n) break; a |= as[ais[j]]; li = ais[j]; } } cout << res << '\n'; return 0; }