#include <bits/stdc++.h>
using namespace std;
long long a[100050];
void init() {
  for (long long i = 0; i <= 100048; i++) {
    long long x = i;
    a[i] = 0;
    while (x > 0) {
      if (x % 2 == 1) a[i]++;
      x /= 2;
    }
  }
}
long long n, k;
long long b[10050];
int main() {
  scanf("%lld%lld", &n, &k);
  memset(b, 0, sizeof(b));
  for (long long i = 1; i <= n; i++) {
    long long x;
    scanf("%lld", &x);
    b[x]++;
  }
  init();
  if (k == 0) {
    long long res = 0;
    for (long long i = 0; i <= 10000; i++) {
      if (b[i] > 1) {
        res += (b[i] * (b[i] - 1)) / 2;
      }
    }
    printf("%lld\n", res);
    return 0;
  }
  long long ans = 0;
  for (long long i = 0; i <= 10000; i++) {
    for (long long j = 0; j <= 10000; j++) {
      if (i == j) continue;
      long long c = (i ^ j);
      c = a[c];
      if (c == k) {
        ans += (b[i] * b[j]);
      }
    }
  }
  ans /= 2;
  printf("%lld\n", ans);
}
