#include <bits/stdc++.h>
using namespace std;
const int mxn = 1e6 + 10;
const int mxlg = 14;
const int mod = 1e9 + 7;
int cnt[mxn];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    cnt[x]++;
  }
  if (!k) {
    long long ans = 0;
    for (int i = 0; i <= 10000; i++) {
      ans += 1ll * (cnt[i] - 1) * cnt[i] / 2;
    }
    cout << ans << '\n';
    return 0;
  }
  long long ans = 0;
  for (int num = 0; num <= 10000; num++) {
    int set = (1 << k) - 1;
    int limit = (1 << mxlg);
    while (set < limit) {
      ans += 1ll * cnt[num ^ set] * cnt[num];
      int c = set & -set;
      int r = set + c;
      set = (((r ^ set) >> 2) / c) | r;
    }
  }
  ans /= 2;
  cout << ans << '\n';
  return 0;
}
