#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 5;
int cnt[N];
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    ++cnt[x];
  }
  long long ans = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i; j < N; ++j) {
      if (i == j && k == 0)
        ans += cnt[i] * 1ll * (cnt[i] - 1) >> 1ll;
      else
        ans += __builtin_popcount(i ^ j) == k ? cnt[i] * 1ll * cnt[j] : 0;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
