#!/usr/bin/env python3

def main():
  with open("game.in", "r") as fin:
    n, K = map(int, fin.readline().split())
    a = list(map(int, fin.readline().split()))
  a.sort()
  m = 0
  cnt = list()
  val = list()
  for i in range(n):
    if (i == 0) or (a[i] != a[i - 1]):
      m += 1
      cnt.append(1)
      val.append(a[i])
    else:
      cnt[m - 1] += 1

  ans = 0
  for i in range(m):
    cnt[i] -= 1
    border = val[i] * K
    for k in range(i, m):
      if (border < val[k]):
        break
      if (cnt[k] == 0):
        continue
      cnt[k] -= 1
      for j in range(i, k + 1):
        if (cnt[j] == 0):
          continue
        temp = 0
        if (i == j):
          temp += 1
        if (j == k):
          temp += 1
        if temp == 0:
          ans += 6
        elif temp == 1:
          ans += 3
        else:
          ans += 1
      cnt[k] += 1
    cnt[i] += 1

  with open("game.out", "w") as fout:
    fout.write(str(ans) + "\n")


if __name__ == "__main__":
    main()

