#include <bits/stdc++.h>
using namespace std;
const int N = (1 << 14);
long long ent[N], t;
long long qan[N];
int bitNum(int n) {
  int ans = 0;
  while (n) {
    ans += n & 1;
    n >>= 1;
  }
  return ans;
}
void make_ent(int k) {
  for (int i = 0; i < N; ++i) {
    if (bitNum(i) == k) ent[t++] = i;
  }
}
int main() {
  int n, k;
  cin >> n >> k;
  make_ent(k);
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    qan[a]++;
  }
  long long ans = 0;
  if (k != 0) {
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < t; ++j) {
        ans += qan[ent[j] ^ i] * qan[i];
      }
    }
  } else {
    for (int i = 0; i < N; ++i) {
      ans += qan[i] * (qan[i] - 1);
    }
  }
  cout << ans / 2 << endl;
  return 0;
}
