#include <bits/stdc++.h>
using namespace std;
void task();
int main() {
  srand(time(0));
  task();
  return 0;
}
const int INF = 0x3f3f3f3f;
const int N = 1e6 + 10;
const int M = 1e7 + 100;
const int OLOLO = 0xFFFFFFFF;
int n, k;
long long int cnt[N];
set<int> vals;
long long int ans;
vector<int> masks;
void task() {
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    ++cnt[a];
    vals.insert(a);
  }
  for (int i = 0; i < (1 << 14); ++i) {
    if (__builtin_popcount(i) == k) {
      masks.push_back(i);
    }
  }
  for (int val : vals) {
    for (int mask : masks) {
      int result = val & (mask ^ OLOLO);
      result |= (val ^ OLOLO) & mask;
      if (result < N) {
        if (val == result) {
          ans += cnt[val] * (cnt[val] - 1);
        } else {
          ans += cnt[val] * cnt[result];
        }
      }
    }
  }
  cout << ans / 2;
}
