#include <bits/stdc++.h>
template <typename T>
T read() {
  T x;
  std::cin >> x;
  return x;
}
int btc(int x) {
  int ans = 0;
  while (x > 0) {
    x &= x - 1;
    ans++;
  }
  return ans;
}
int main() {
  auto dst = std::array<int, 20000>();
  auto a = std::array<int, 10001>();
  for (auto i = 0; i < dst.size(); i++) {
    dst[i] = btc(i);
  }
  auto n = read<int>();
  auto k = read<int>();
  for (auto i = 0; i < n; i++) {
    auto x = read<int>();
    a[x]++;
  }
  auto ans = 0LL;
  for (auto i = 0; i < a.size(); i++) {
    auto first = (long long)a[i];
    auto second = 0LL;
    if (k == 0) {
      second = a[i] - 1;
      if (first % 2 == 0)
        first /= 2;
      else
        second /= 2;
    } else {
      for (auto j = i + 1; j < a.size(); j++) {
        if (dst[i ^ j] == k) {
          second += a[j];
        }
      }
    }
    ans += first * second;
  }
  std::cout << ans << std::endl;
  return 0;
}
