#include <bits/stdc++.h>
using namespace std;
using namespace std;
const int N = (int)1e6 + 7;
const int MOD = (int)1e9 + 7;
const int P = (int)1e4 + 7;
int a[N], cnt[N];
vector<vector<int> > d(P);
bool valid(int x, int y, int k) {
  int d = 0;
  for (int i = 0; i < 14; i++) {
    if ((x & (1 << i)) != (y & (1 << i))) d++;
  }
  return d == k;
}
int main() {
  ios_base::sync_with_stdio(0);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  if (k == 0) {
    for (int i = 0; i < P; i++) d[i].push_back(i);
  } else {
    for (int i = 0; i < P; i++) {
      for (int j = i + 1; j < P; j++) {
        if (valid(i, j, k)) d[i].push_back(j), d[j].push_back(i);
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    for (auto x : d[a[i]]) ans += 1ll * cnt[x];
    cnt[a[i]]++;
  }
  cout << ans;
  return 0;
}
