#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long> > d;
int32_t main() {
  ios_base::sync_with_stdio(false);
  long long n, k;
  cin >> n >> k;
  vector<long long> v(n);
  vector<long long> d(1e4 + 7);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
    ++d[v[i]];
  }
  long long a = 0;
  for (int i = 0; i <= 1e4 + 2; ++i) {
    for (int j = i; j <= 1e4 + 2; ++j) {
      int mask = i ^ j;
      if (__builtin_popcount(mask) == k) {
        if (i == j)
          a += (d[i] * (d[i] - 1)) / 2;
        else
          a += d[i] * d[j];
      }
    }
  }
  cout << a;
}
