#include <bits/stdc++.h>
using namespace std;
template <typename T>
T abs(T x) {
  return x > 0 ? x : -x;
}
template <typename T>
T sqr(T x) {
  return x * x;
}
int n, k, a[100005];
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a[x]++;
  }
  vector<int> masks;
  for (int i = 0; i < 16384; i++) {
    if (__builtin_popcount(i) == k) masks.push_back(i);
  }
  long long ans = 0;
  for (int i = 0; i <= 10000; i++) {
    if (a[i] > 0) {
      for (int j = 0; j < masks.size(); j++)
        ans += (long long)(a[i] - (k == 0 ? 1 : 0)) * 1LL *
               (long long)a[i ^ masks[j]];
    }
  }
  cout << ans / 2LL;
  return 0;
}
