#include <bits/stdc++.h>
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using namespace std;
const ll mod = 1e9 + 7;
const int N = 3e5 + 5;
int arr[10001]{};
int no(int num) {
  int c = 0;
  while (num) {
    c++;
    num &= (num - 1);
  }
  return c;
}
void test_case() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    arr[a]++;
  }
  ll c = 0;
  for (int i = 0; i <= 10000; i++) {
    for (int j = i; j <= 10000; j++) {
      if (no(i ^ j) == k) {
        if (i == j)
          c += (arr[i] * 1ll * (arr[j] - 1) / 2);
        else
          c += (arr[i] * 1ll * arr[j]);
      }
    }
  }
  cout << c;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  test_case();
  return 0;
}
