#include <bits/stdc++.h>
using namespace std;
int const INF = numeric_limits<int>::max();
inline int count_ones(int a) {
  int ans = 0;
  while (a > 0) {
    ans += a & 1;
    a >>= 1;
  }
  return ans;
}
int const MAX = pow(2, 16);
int const N = 1e5 + 5;
int a[N];
long long m[N];
int main() {
  ios::sync_with_stdio(false);
  vector<int> v;
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < MAX; i++) {
    if (count_ones(i) == k) {
      v.push_back(i);
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    for (auto mask : v) {
      ans += m[mask ^ x];
    }
    m[x]++;
  }
  cout << ans << endl;
  return 0;
}
