#include <bits/stdc++.h>
using namespace std;
long long cnt[100000];
long long count0[100000];
long long bitcount(long long x) {
  long long b;
  for (b = 0; x != 0; x >>= 1)
    if (x & 01) b++;
  return b;
}
int main() {
  long long n, k;
  long long sum = 0;
  cin >> n >> k;
  long long a[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    cnt[a[i]]++;
  }
  for (long long i = 0; i < 100000; i++) count0[i] = bitcount(i);
  if (k != 0) {
    for (long long i = 0; i <= 10000; i++) {
      for (long long j = i + 1; j <= 10000; j++) {
        if (count0[i ^ j] == k) {
          sum += cnt[i] * cnt[j];
        }
      }
    }
  } else
    for (long long i = 0; i <= 10000; i++) sum += cnt[i] * (cnt[i] - 1) / 2;
  cout << sum;
}
