#include <cstdio>
#include <cassert>
#include <algorithm>
#include <vector>
#include <iostream>

using std::sort;
using std::vector;
using std::min;

typedef long long ll;
typedef std::pair<int,int> pii;

const int MAX = 111;
bool use[MAX][MAX][MAX];

inline int check(int a, int b, int K) {
  return a >= (b + K - 1) / K;
}

int main() {
  assert(freopen("game.in", "r", stdin));
  assert(freopen("game.out", "w", stdout));

  int n, K;
  scanf("%d%d", &n, &K);
  vector <int> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  sort(a.begin(), a.end());
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    if (i && a[i] == a[i - 1]) { continue; }
    for (int k = i + 2; k < n; ++k) {
      if (!check(a[i], a[k], K)) { break; }
      if (k + 1 < n && a[k] == a[k + 1]) { continue; }
      for (int j = i + 1; j < k; ++j) {
        if (j > i + 1 && a[j] == a[j - 1]) { continue; }
        int cnt = 0;
        if (a[i] == a[j]) { ++cnt; }
        if (a[j] == a[k]) { ++cnt; }
        ans += (cnt == 0 ? 6 : (cnt == 1 ? 3 : 1));
      }
    }
  }
  std::cout << ans << std::endl;

  return 0;
}
