#include <bits/stdc++.h>
using namespace std;
const int IINF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fll;
const double DINF = numeric_limits<double>::infinity();
const long long MOD = 1000000007;
const double EPS = 1e-9;
const int DX[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int DY[] = {0, 1, 0, -1, 1, -1, -1, 1};
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long sqr(long long x) { return x * x; }
long long sqr(int x) { return (long long)x * x; }
double sqr(double x) { return x * x; }
long double sqr(long double x) { return x * x; }
const int N = 100179;
int n, k, a[N];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; ++i) scanf("%d", a + i);
  long long ans = 0;
  for (int xr = 0; xr < 1 << 14; ++xr) {
    if (__builtin_popcount(xr) != k) continue;
    static int cnt[1 << 14];
    memset(cnt, 0, sizeof(cnt));
    for (int i = 0; i < n; ++i) {
      ans += cnt[a[i] ^ xr];
      ++cnt[a[i]];
    }
  }
  cout << ans << "\n";
  return 0;
}
