#include <bits/stdc++.h>
using namespace std;
long long ans = 0;
int n, k, p, sz;
int a[10005];
vector<int> v;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  memset(a, 0, sizeof a);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> p;
    a[p]++;
  }
  for (int i = 0; i < 10001; i++)
    if (a[i] != 0) v.push_back(i);
  sz = v.size();
  for (int i = 0; i < sz; i++) {
    if (k == 0) ans += (1LL * a[v[i]] * (a[v[i]] - 1)) / 2;
    for (int j = i + 1; j < sz; j++) {
      if (__builtin_popcount(v[i] ^ v[j]) == k) ans += 1LL * a[v[i]] * a[v[j]];
    }
  }
  cout << ans << endl;
}
