#include <bits/stdc++.h>
using namespace std;
int a[10001], u[1 << 14];
int main() {
  int n, k;
  cin >> n >> k;
  for (int t; cin >> t;) a[t]++;
  for (int i = 1; i < (1 << 14); i++) u[i] = u[i / 2] + i % 2;
  long long s = 0;
  if (k) {
    for (int i = 0; i <= 10000; i++)
      for (int j = i + 1; j <= 10000; j++)
        if (u[i ^ j] == k) s += 1ll * a[i] * a[j];
  } else {
    for (int i = 0; i <= 10000; i++) s += 1ll * a[i] * (a[i] - 1) / 2;
  }
  cout << s;
}
