#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
vector<int> kxor;
int k;
void generate(int k1, int l, int num) {
  if (k1 == k) {
    kxor.push_back(num);
    return;
  }
  if (l == 14) return;
  generate(k1, l + 1, num);
  generate(k1 + 1, l + 1, num + (1 << l));
}
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n >> k;
  vector<int> a(n);
  vector<int> freq(1e5 + 31, 0);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    freq[a[i]]++;
  }
  generate(0, 0, 0);
  int64_t res = 0;
  for (int i = 0; i < n; ++i) {
    freq[a[i]]--;
    for (int j = 0; j < kxor.size(); ++j) {
      res += freq[a[i] ^ kxor[j]];
    }
  }
  cout << res;
}
