#include <bits/stdc++.h>
using namespace std;
int n, k;
int a[111111];
int cnt[111111];
long long ans;
vector<int> masks;
void solve(int a) {
  for (int i = 0; i < (int)masks.size(); ++i) {
    ans += cnt[a ^ masks[i]];
  }
}
bool good(int mask) {
  int ans = 0;
  for (int i = 0; i < 14; ++i) {
    if (mask & (1 << i)) ans++;
  }
  return (ans == k);
}
void init() {
  for (int i = 0; i < (1 << 14); ++i) {
    if (good(i)) masks.push_back(i);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  init();
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    solve(a[i]);
    cnt[a[i]]++;
  }
  cout << ans;
  return 0;
}
