#include <bits/stdc++.h>
using namespace std;
int n, k;
long long int cnt[10002];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> k;
  int i, j;
  for (i = 1; i <= n; ++i) {
    cin >> j;
    cnt[j]++;
  }
  vector<int> chck;
  long long int ans = 0;
  for (i = 0; i <= 10000; ++i) {
    if (cnt[i]) {
      chck.push_back(i);
      ans = ans + (cnt[i] * (cnt[i] - 1)) / 2;
    }
  }
  if (k == 0) {
    cout << ans << endl;
    return 0;
  }
  ans = 0;
  int m, diff;
  for (i = 0; i < chck.size(); ++i) {
    for (j = i + 1; j < chck.size(); ++j) {
      diff = 0;
      m = chck[i] ^ chck[j];
      while (m) {
        if (m & 1) {
          ++diff;
        }
        m = m >> 1;
      }
      if (diff == k) {
        ans = ans + cnt[chck[i]] * cnt[chck[j]];
      }
    }
  }
  cout << ans << endl;
  return 0;
}
