#include <bits/stdc++.h>
using namespace std;
long long a[200005], cnt[200005];
int n, k;
long long ans;
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cnt[a[i]]++;
  }
  int mx = 1 << 14;
  if (k == 0) {
    for (int i = 0; i <= mx; i++) ans += cnt[i] * (cnt[i] - 1) / 2;
    cout << ans << endl;
    return 0;
  }
  for (int i = 1; i <= mx; i++) {
    long long cur = i;
    int kk = 0;
    while (cur > 0) {
      if (cur % 2) kk++;
      cur /= 2;
    }
    if (kk != k) continue;
    for (int j = 0; j < n; j++) ans += cnt[a[j] ^ i];
  }
  cout << ans / 2 << endl;
}
