#include <bits/stdc++.h>
using namespace std;
long long func(long long n) {
  long long cnt = 0;
  while (n) {
    n &= (n - 1);
    cnt++;
  }
  return cnt;
}
int main() {
  long long i, j, n, k, freq[10005] = {0}, ans = 0, u;
  cin >> n >> k;
  for (i = 0; i < n; i++) {
    cin >> u;
    freq[u]++;
  }
  for (i = 0; i <= 10000; i++) {
    for (j = i; j <= 10000; j++) {
      if (func(i ^ j) == k) {
        if (k == 0)
          ans += (freq[i] * (freq[i] - 1)) / 2;
        else
          ans += freq[i] * freq[j];
      }
    }
  }
  cout << ans << endl;
}
