#include <bits/stdc++.h>
using namespace std;
unsigned long long cnt[10001];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    cnt[a]++;
  }
  unsigned long long ans = 0;
  if (k != 0) {
    for (int i = 0; i <= 10000; i++) {
      if (cnt[i] != 0) {
        for (int e = i + 1; e <= 10000; e++) {
          int a = i;
          int b = e;
          int c = 0;
          while (a > 0 || b > 0) {
            if (a % 2 != b % 2) {
              c++;
            }
            a /= 2;
            b /= 2;
          }
          if (c == k) {
            ans += cnt[i] * cnt[e];
          }
        }
      }
    }
  } else {
    for (int i = 0; i <= 10000; i++) {
      if (cnt[i] >= 2) {
        ans += (cnt[i] * (cnt[i] - 1)) / 2;
      }
    }
  }
  cout << ans;
  return 0;
}
