#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  long long k;
  cin >> n >> k;
  vector<long long> vec(10001, 0);
  for (long long i = 1; i <= n; i++) {
    long long x;
    cin >> x;
    vec[x]++;
  }
  long long answer = 0;
  for (long long i = 0; i < 10001; i++)
    for (long long j = i; j < 10001; j++)
      if (vec[i] > 0 && vec[j] > 0) {
        long long l = i ^ j;
        if (__builtin_popcount(l) == k && i != j)
          answer += vec[i] * vec[j];
        else if (i == j && k == 0)
          answer += ((vec[i] - 1) * vec[j]) / 2;
      }
  cout << answer << endl;
  return 0;
}
