#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const int N = 1e5 + 5;
const int INF = 2e9;
const lint LINF = 9e18;
const int MAX_ELM = 1e4;
int n, k;
int a[N], freq[MAX_ELM + 5];
vector<int> teman[MAX_ELM + 5];
void precompute() {
  if (k == 0) {
    for (int i = 0; i <= MAX_ELM; i++) {
      teman[i].push_back(i);
    }
  } else {
    for (int i = 0; i <= MAX_ELM; i++) {
      for (int j = i + 1; j <= MAX_ELM; j++) {
        if (__builtin_popcount(i ^ j) == k) {
          teman[i].push_back(j);
          teman[j].push_back(i);
        }
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  precompute();
  lint ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int x : teman[a[i]]) {
      ans += freq[x];
    }
    freq[a[i]]++;
  }
  cout << ans << "\n";
}
