#include <bits/stdc++.h>
using namespace std;
const int Z = (int)1e5 + 111;
const int INF = (int)1e9 + 111;
const int MODF = (int)1e9 + 7;
const double EPS = 1e-6;
long long a[Z], b[Z], ans;
int main() {
  int n, k, x;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> x;
    a[x]++;
  }
  for (int i = 0; i <= 10000; i++)
    for (int j = i + 1; j <= 10000; j++) b[i ^ j] += a[i] * a[j];
  for (int i = 0; i <= 10000; i++) b[i ^ i] += a[i] * (a[i] - 1) / 2;
  for (int i = 0; i <= 10000 * 2; i++) {
    int cnt_b = 0;
    for (int j = 0; j <= 15; j++) cnt_b += (i >> j) & 1;
    if (cnt_b == k) ans += b[i];
  }
  cout << ans;
  return 0;
}
