#include <bits/stdc++.h>
using namespace std;
int cnt[1 << 14];
signed main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(0);
  int n, k, maxn = 0;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    maxn = max(maxn, a);
    ++cnt[a];
  }
  long long ans = 0;
  if (k == 0) {
    for (int i = 0; i <= maxn; ++i) ans += cnt[i] * (cnt[i] - 1LL) / 2;
    cout << ans << '\n';
    return 0;
  }
  int l = 32 - __builtin_clz(max(1, maxn));
  for (int i = 0; i < (1 << l); ++i) {
    if (__builtin_popcount(i) != l - k) continue;
    for (int j = 0; j <= maxn; ++j)
      ans += 1LL * cnt[j] * cnt[(j & i) | (~j & ~i & ((1 << l) - 1))];
  }
  cout << ans / 2 << '\n';
  return 0;
}
