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

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

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

const int MAX = 111;
bool use[MAX][MAX][MAX];
set <Triple> use_tr;

int check(int a, int b, int K) {
  return a * K >= b && b * K >= a;
}

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]);
  }
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i == j) { continue; }
      for (int k = 0; k < n; ++k) {
        if (i == k || j == k) { continue; }
        if (check(a[i], a[j], K) && check(a[i], a[k], K) && check(a[j], a[k], K)) {
          if (a[i] <= MAX && a[j] <= MAX && a[k] <= MAX) {
            if (!use[a[i]][a[j]][a[k]]) {
              ++ans;
              use[a[i]][a[j]][a[k]] = 1;
            }
          } else {
            Triple zzz(a[i], pii(a[j], a[k]));
            if (!use_tr.count(zzz)) {
              ++ans;
              use_tr.insert(zzz);
            }
          }
        }
      }
    }
  }
  std::cout << ans << std::endl;

  return 0;
}
