#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 9;
const long long N = 500500;
long long spd[N];
map<vector<pair<long long, long long> >, long long> p;
void sieve() {
  for (long long i = 2; i < N; i++) {
    if (spd[i] == 0) {
      for (long long j = i; j < N; j += i) {
        spd[j] = i;
      }
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  sieve();
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    map<long long, long long> mp;
    while (a[i] != 1) {
      mp[spd[a[i]]]++;
      a[i] = a[i] / spd[a[i]];
    }
    vector<pair<long long, long long> > t;
    for (auto z : mp) {
      long long md = z.second % k;
      if (md != 0) {
        t.push_back({z.first, md});
      }
    }
    p[t]++;
  }
  long long ans = 0, extra = 0;
  for (auto z : p) {
    vector<pair<long long, long long> > t;
    for (auto w : z.first) {
      t.push_back({w.first, k - w.second});
    }
    if (t != z.first)
      ans += z.second * p[t];
    else
      extra += z.second * (z.second - 1) / 2;
  }
  cout << ans / 2 + extra;
  return 0;
}
