#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
long long raw[maxn], cnt[maxn], yay[maxn];
int main() {
  long long n, k, idx = 0;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> raw[i];
    cnt[raw[i]]++;
  }
  if (k == 2) {
    long long ans = 0;
    memset(cnt, 0, sizeof(cnt));
    for (int i = 1; i <= n; i++) {
      for (int j = 2; j * j <= raw[i]; j++) {
        long long xwx = j * j;
        while (raw[i] % xwx == 0) raw[i] /= xwx;
      }
      cnt[raw[i]]++;
    }
    for (int i = 1; i <= 1e5; i++)
      if (cnt[i]) ans += (1LL * cnt[i] * (cnt[i] - 1) / 2);
    cout << ans;
    return 0;
  }
  for (int i = 1; i <= 1e5; i++) {
    long long u = i;
    bool ok = 1;
    for (int j = 1; j < k; j++) {
      u *= i;
      if (u > 1e10 + 1) {
        ok = 0;
        break;
      }
    }
    if (ok) yay[++idx] = u;
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    long long u = raw[i];
    cnt[u]--;
    for (int j = 1; j <= idx; j++) {
      long long x = yay[j];
      if (x >= (maxn)*u) break;
      if (x % u == 0) {
        ans += cnt[x / u];
      }
    }
    cnt[u]++;
  }
  cout << ans / 2 << endl;
  return 0;
}
