#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 100000;
const int MAXBIT = 13;
int n, want;
int opt[2 << MAXBIT], nopt;
int cnt[2 << MAXBIT];
void run() {
  scanf("%d%d", &n, &want);
  memset(cnt, 0, sizeof(cnt));
  for (int i = (0); i < (n); ++i) {
    int a;
    scanf("%d", &a);
    ++cnt[a];
  }
  for (int i = (0); i < (2 << MAXBIT); ++i) {
    int cur = 0;
    for (int j = (0); j <= (MAXBIT); ++j)
      if (i & (1 << j)) ++cur;
    if (cur == want) opt[nopt++] = i;
  }
  long long ret = 0;
  for (int i = (0); i < (2 << MAXBIT); ++i)
    for (int j = (0); j < (nopt); ++j) {
      int ii = i ^ opt[j];
      if (i == ii)
        ret += (long long)cnt[i] * (cnt[i] - 1);
      else
        ret += (long long)cnt[i] * cnt[ii];
    }
  assert(ret % 2 == 0);
  printf("%lld\n", ret / 2);
}
int main() {
  run();
  return 0;
}
