#include <bits/stdc++.h>
using namespace std;
int a[20001] = {0};
long long b[20001] = {0};
int f(int x) {
  int k = 0;
  while (x) {
    k += x % 2;
    x /= 2;
  }
  return k;
}
int main() {
  int i, j, n, k, x;
  long long ans = 0;
  for (i = 0; i <= 20000; i++) {
    a[i] = f(i);
  }
  scanf("%i%i", &n, &k);
  for (i = 1; i <= n; i++) {
    scanf("%i", &x);
    b[x]++;
  }
  for (i = 0; i <= 10000; i++) {
    for (j = i + 1; j <= 10000; j++) {
      if (a[i ^ j] == k) {
        ans += b[i] * b[j];
      }
    }
  }
  for (i = 0; i <= 10000; i++) {
    if (a[i ^ i] == k) {
      ans += b[i] * (b[i] - 1) / 2;
    }
  }
  cout << ans << endl;
  return 0;
}
