#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 7;
long long a[maxn], b[maxn], num[maxn];
long long sq[maxn], db[maxn], prime[maxn], cnt;
bool check[maxn];
long long flashpow(long long a, long long b) {
  long long ans = 1, base = a;
  while (b) {
    if (b & 1) {
      ans *= base;
    }
    b >>= 1;
    base *= base;
  }
  return ans;
}
void Prime() {
  for (int i = 2; i < maxn; i++) {
    if (!check[i]) prime[++cnt] = i;
    for (int j = 1; j <= cnt && i * prime[j] < maxn; j++) {
      check[i * prime[j]] = true;
      if (i % prime[j] == 0) break;
    }
  }
}
int n, t, k;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  if (k == 2) {
    Prime();
    for (int i = 1; i <= cnt; i++) {
      prime[i] = prime[i] * prime[i];
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= cnt; j++) {
        if (prime[j] > a[i]) break;
        while (a[i] % prime[j] == 0) a[i] /= prime[j];
      }
      num[a[i]]++;
    }
    long long ans = 0;
    for (int i = 1; i <= maxn - 7; i++) {
      ans += num[i] * (num[i] - 1) / 2;
    }
    cout << ans << endl;
  }
  if (k != 2) {
    sort(a + 1, a + 1 + n);
    int cnt = 1;
    num[a[1]]++;
    b[1] = a[1];
    for (int i = 2; i <= n; i++) {
      if (a[i] == b[cnt]) {
        num[b[cnt]]++;
        continue;
      }
      b[++cnt] = a[i];
      num[a[i]]++;
    }
    int cntt = 0;
    for (long long i = 1;; i++) {
      db[i] = flashpow(i, k);
      cntt++;
      if (k > 60) break;
      if (db[i] > 10000000000) break;
    }
    long long ans = 0;
    for (int i = 1; i <= cnt; i++) {
      for (int j = 1; j <= cntt; j++) {
        if (db[j] % b[i] != 0) continue;
        if (db[j] / b[i] > 100000) continue;
        if (num[db[j] / b[i]] == 0) continue;
        if (db[j] / b[i] == b[i] && num[db[j] / b[i]] > 0)
          ans += (num[db[j] / b[i]] * (num[db[j] / b[i]] - 1) / 2);
        else
          ans += num[b[i]] * num[db[j] / b[i]];
      }
      num[b[i]] = 0;
    }
    cout << ans << endl;
  }
}
