#include <bits/stdc++.h>
using namespace std;
const int N = 228228;
int a[N], bit[N];
long long cnt[N];
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    cnt[a[i]]++;
  }
  long long ans = 0LL;
  for (int i = 0; i <= 100000; ++i) {
    for (int j = 0; j <= 15; ++j) {
      bit[i] += (1 & (i >> j));
    }
  }
  for (int i = 0; i <= 10000; ++i) {
    for (int j = i + 1; j <= 10000; ++j) {
      if (bit[(i ^ j)] == k) {
        if (i != j) {
          ans += 1LL * (cnt[i] * cnt[j]);
        }
      }
    }
  }
  if (k == 0) {
    for (int i = 0; i <= 10000; ++i) {
      ans += 1LL * cnt[i] * (cnt[i] - 1) / 2;
    }
  }
  cout << ans << endl;
  return 0;
};
