#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return ((a * b) / gcd(a, b)); }
const long long maxn = 1e5;
long long n, k;
vector<long long> freq(maxn, 0);
vector<long long> arr(maxn);
vector<long long> ans(maxn, 0);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  cin >> n >> k;
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
    freq[arr[i]]++;
  }
  long long counter = 0;
  for (long long i = 0; i < 1e4 + 1; i++) {
    if (freq[i] > 0) {
      for (long long j = i; j < 1e4 + 1; j++) {
        if (freq[j] == 0) {
          continue;
        }
        long long now = i ^ j;
        if (__builtin_popcount(now) == k) {
          if (i == j) {
            counter += ((freq[i] * (freq[i] - 1)) / 2);
            continue;
          }
          counter += ((freq[i] * freq[j]));
        }
      }
    }
  }
  cout << counter;
  return 0;
}
