#include <bits/stdc++.h>
using namespace std;
long long MOD = int(1e9) + 7;
int debug = 1;
const int N = int(1e5) + 5;
using namespace std;
int a[N];
long long freq[N];
long long dp[5000][105];
long long mul(int a, int b) {
  if (dp[a][b] != -1) return dp[a][b];
  long long &ret = dp[a][b];
  ret = 1;
  while (b--) {
    if (ret > (long long)1e11 / a) {
      ret = 1e11;
      continue;
    }
    ret *= a;
  }
  return ret;
}
int main() {
  int i, j, n, t, m;
  ios::sync_with_stdio(false);
  memset(dp, -1, sizeof(dp));
  int k;
  cin >> n >> k;
  for (i = 0; i < n; i++) cin >> a[i];
  if (k == 2) {
    long long ans = 0;
    for (i = 0; i < n; i++) {
      int t = a[i], req = 1;
      for (j = 2; j * j <= t; j++) {
        if (t % j) continue;
        int cur = 0;
        while (t % j == 0) {
          t /= j;
          cur ^= 1;
        }
        if (cur) req *= j;
      }
      if (t > 1) req *= t;
      ans += freq[req];
      freq[req]++;
    }
    cout << ans;
  } else {
    long long c = (long long)1e10;
    long long ans = 0;
    for (i = 0; i < n; i++) {
      for (j = 1;; j++) {
        long long cur = mul(j, k);
        if (cur > c) break;
        if (cur % a[i] == 0 && cur / a[i] < N) ans += freq[cur / a[i]];
      }
      freq[a[i]]++;
    }
    cout << ans;
  }
}
