#include <bits/stdc++.h>
using namespace std;
const int inf = 1.01e9;
const double eps = 1e-9;
const int N = 1e5 + 10;
const int MX = 1 << 17;
int a[N];
int cnt[MX];
int bc[MX];
int main() {
  for (int i = 0; (i) < (MX); ++i) bc[i] = bc[i >> 1] + (i & 1);
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 0; (i) < (n); ++i) scanf("%d", &a[i]);
  for (int i = 0; (i) < (n); ++i) cnt[a[i]]++;
  long long res = 0;
  if (k == 0) {
    for (int i = 0; (i) < (MX); ++i)
      res += cnt[i] * (long long)(cnt[i] - 1) / 2;
  } else {
    int mx = 1e4 + 1;
    for (int i = 0; (i) < (mx); ++i)
      for (int j = 0; (j) < (i); ++j)
        if (bc[i ^ j] == k) {
          res += cnt[i] * (long long)cnt[j];
        }
  }
  printf("%I64d\n", res);
  return 0;
}
