#include<bits/stdc++.h>
using namespace std;

int idk[32][100001];
int calc(int a, int b) {
    int c = 0;
    for(int i = 31; i >= 0; i--) {
        c*=2;
        if(idk[i][b+1]-idk[i][a]) {
            c++;
        }
    }
    return c;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k,a,b,c,m,l,r,br = 0,sb = 0;
    cin >> n >> k;
    vector<int> haha(n);
    for(int i = 0; i < 32; i++) {
        for(int j = 0; j < 100001; j++) {
            idk[i][j] = 0;
        }
    }
    for(int i = 0; i < n; i++) {
        cin >> a;
        haha[i] = a;
        b = 0;
        while(a > 0) {
            idk[b][i+1] += a%2;
            b++;
            a/=2;
        }
    }
    for(int i = 1; i < 100001; i++) {
        for(int j = 0; j < 32; j++) {
            idk[j][i]+=idk[j][i-1];
        }
    }
    for(int i = 0; i < n; i++) {
        l = 0;
        r = i;
        sb=haha[i]|sb;
        if(sb < k) {
            continue;
        }
        while(l != r) {
            m = (l+r+1)/2;
            if(calc(m,i) >= k) {
                l = m;
            }
            else {
                r = m-1;
            }
        }
        br+=l+1;
    }
    cout << br;
    return 0;
}
