#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5, MX = 1e4 + 5;
int freq[10 * MX];
int solve(int i, int k, int cur, int num) {
  if (i == 15) {
    if (k == 0) return freq[cur];
    return 0;
  }
  int ret = solve(i + 1, k, cur, num);
  if (((num >> i) & 1) && k) ret += solve(i + 1, k - 1, cur - (1 << i), num);
  if ((!((num >> i) & 1)) && k) ret += solve(i + 1, k - 1, cur + (1 << i), num);
  return ret;
}
int main() {
  int n, k;
  long long ans = 0;
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    freq[x]++;
  }
  for (int i = 0; i < MX; i++) {
    if (k == 0)
      ans += 1ll * freq[i] * (freq[i] - 1) / 2;
    else
      ans += 1ll * freq[i] * solve(0, k, i, i);
    freq[i] = 0;
  }
  printf("%lld\n", ans);
  return 0;
}
