#include <bits/stdc++.h>
using namespace std;
vector<vector<vector<long long>>> dp;
map<int, int> mm;
int main() {
  int n, k;
  cin >> n >> k;
  dp.resize(20001, vector<vector<long long>>(15, vector<long long>(15)));
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    dp[t][0][0]++;
  }
  long long ans = 0;
  if (k == 0) {
    for (int i = 0; i < 20001; i++) {
      ans += dp[i][0][0] * (dp[i][0][0] - 1) / 2;
    }
    cout << ans << endl;
    return 0;
  }
  for (int j = 1; j <= k; j++) {
    for (int i = 0; i < 20001; i++) {
      for (int pos = 14; pos >= 1; pos--) {
        if ((i ^ (1 << (pos - 1))) < 20001 &&
            (j > 1 || (j == 1 && (i & (1 << (pos - 1)))))) {
          for (int l = 0; l < pos; l++) {
            int nm = (i ^ (1 << (pos - 1))) | ((1 << (pos - 1)) - 1);
            dp[i][j][pos] += dp[(i ^ (1 << (pos - 1)))][j - 1][l];
          }
        }
      }
    }
  }
  ans = 0;
  for (int i = 0; i < 10001; i++) {
    if (dp[i][0][0] == 0) continue;
    for (int jj = 0; jj < 15; jj++) ans += dp[i][k][jj] * dp[i][0][0];
  }
  cout << ans << endl;
  return 0;
}
