#include <bits/stdc++.h>
void fo() { fflush(stdout); }
using namespace std;
int frq[10001];
int cnt(int x) {
  int ans = 0;
  for (int i = 30; ~i; i--) {
    if (((1 << i) & x)) ans++;
  }
  return ans;
}
long long cn(int x) {
  if (x <= 1) return 0;
  return (1LL * (x - 1) * x) / 2;
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    frq[t]++;
  }
  long long ans = 0;
  for (int i = 0; i <= 10000; i++)
    for (int j = i + 1; j <= 10000; j++) {
      if (frq[i] && frq[j] && cnt((i ^ j)) == m) {
        ans += 1LL * frq[i] * frq[j];
      }
    }
  if (m == 0) {
    for (int i = 0; i <= 10000; i++) {
      ans += cn(frq[i]);
    }
  }
  cout << ans << "\n";
  return 0;
}
