#include <bits/stdc++.h>
using namespace std;
long long A[10000 + 5];
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    A[a]++;
  }
  long long solve = 0ll;
  for (int i = 0; i <= 10000; i++) {
    for (int j = i; j <= 10000; j++) {
      if (__builtin_popcount(i ^ j) == k && A[i] != 0 && A[j] != 0) {
        if (i != j)
          solve += 1ll * A[i] * A[j];
        else
          solve += 1ll * A[i] * (A[i] - 1);
      }
    }
  }
  if (k == 0) solve /= 2;
  cout << solve << '\n';
}
