#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  const int N = 1000;
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  if (k == 2) {
    map<pair<vector<int>, int>, int> cnt;
    for (int i = 0; i < n; i++) {
      vector<int> divs(N);
      for (int j = 2; j < N; j++) {
        while (a[i] % j == 0) {
          a[i] /= j;
          divs[j]++;
        }
        divs[j] %= k;
      }
      cnt[make_pair(divs, a[i])]++;
    }
    long long sum = 0;
    for (auto i : cnt) {
      vector<int> divs, inv_divs(N);
      int big_prime, num;
      tie(divs, big_prime) = i.first;
      num = i.second;
      for (int j = 0; j < (int)divs.size(); j++) {
        inv_divs[j] = (k - divs[j]) % k;
      }
      if (divs == inv_divs) {
        sum += 1LL * num * (num - 1);
      } else {
        sum += 1LL * num * cnt[make_pair(inv_divs, big_prime)];
      }
    }
    cout << sum / 2 << '\n';
    return 0;
  }
  if (k > 2) {
    map<vector<int>, int> cnt;
    for (int i = 0; i < n; i++) {
      vector<int> divs(N);
      for (int j = 2; j < N; j++) {
        while (a[i] % j == 0) {
          a[i] /= j;
          divs[j]++;
        }
        divs[j] %= k;
      }
      if (a[i] == 1) cnt[divs]++;
    }
    long long sum = 0;
    for (auto i : cnt) {
      vector<int> divs, inv_divs(N);
      int num;
      tie(divs, num) = i;
      for (int j = 0; j < (int)divs.size(); j++) {
        inv_divs[j] = (k - divs[j]) % k;
      }
      if (divs == inv_divs) {
        sum += 1LL * num * (num - 1);
      } else {
        sum += 1LL * num * cnt[inv_divs];
      }
    }
    cout << sum / 2 << '\n';
    return 0;
  }
}
