#include <bits/stdc++.h>
using namespace std;
int f[10100], k, n, x;
bool XO[20100];
long long rez;
int main() {
  cin >> n >> k;
  while (n--) {
    cin >> x;
    f[x]++;
  }
  long long rez = 0;
  for (int i = 0; i < 10010; i++) {
    if (f[i]) {
      for (int j = i; j < 10010; j++) {
        int aux = i ^ j;
        int K = 0;
        while (aux) {
          if (aux % 2) K++;
          aux /= 2;
        }
        if (f[j] && K == k) {
          if (i == j) {
            rez += (1LL * f[i] * (f[i] - 1)) / 2LL;
          } else {
            rez += (1LL * f[i] * f[j]);
          }
        }
      }
    }
  }
  cout << rez;
}
