#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
void print_time() {}
template <class T1, class T2>
ostream& operator<<(ostream& out, pair<T1, T2> pair) {
  return out << "(" << pair.first << ", " << pair.second << ")";
}
template <class T>
ostream& operator<<(ostream& out, vector<T> vec) {
  out << "(";
  for (auto& v : vec) out << v << ", ";
  return out << ")";
}
template <class T>
ostream& operator<<(ostream& out, set<T> vec) {
  out << "(";
  for (auto& v : vec) out << v << ", ";
  return out << ")";
}
template <class L, class R>
ostream& operator<<(ostream& out, map<L, R> vec) {
  out << "(";
  for (auto& v : vec) out << v << ", ";
  return out << ")";
}
long long free2(long long x) {
  for (long long d = 2; d * d <= x; ++d) {
    while (x % (d * d) == 0) {
      x /= d * d;
    }
  }
  return x;
}
int main() {
  cout << fixed << setprecision(20);
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  const long long MAXN = 1e5 + 228;
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n);
  vector<long long> cnt(MAXN);
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
    ++cnt[a[i]];
  }
  if (k == 2) {
    map<long long, long long> cnt;
    for (long long i = 0; i < n; ++i) {
      ++cnt[free2(a[i])];
    }
    long long ans = 0;
    for (auto& [_, v] : cnt) {
      ans += v * (v - 1) / 2;
    }
    cout << ans;
  } else {
    vector<long long> pows;
    for (long long i = 1; i < MAXN; ++i) {
      long long x = 1;
      for (long long p = 0; p < k; ++p) {
        x *= i;
        if (x > MAXN * MAXN) break;
      }
      if (x < MAXN * MAXN) pows.push_back(x);
    }
    long long ans = 0;
    for (long long x = 1; x < MAXN; ++x) {
      if (!cnt[x]) continue;
      for (long long prod : pows) {
        if (prod % x) continue;
        long long y = prod / x;
        if (y >= MAXN) continue;
        if (x != y)
          ans += cnt[x] * cnt[y];
        else
          ans += cnt[x] * (cnt[x] - 1);
      }
    }
    cout << ans / 2;
  }
  print_time();
  return 0;
}
