#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline ostream &operator<<(ostream &_out, const pair<T, U> &_p) {
  _out << _p.first << ' ' << _p.second;
  return _out;
}
template <typename T, typename U>
inline istream &operator>>(istream &_in, pair<T, U> &_p) {
  _in >> _p.first >> _p.second;
  return _in;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const vector<T> &_v) {
  if (_v.empty()) {
    return _out;
  }
  _out << _v.front();
  for (auto _it = ++_v.begin(); _it != _v.end(); ++_it) {
    _out << ' ' << *_it;
  }
  return _out;
}
template <typename T>
inline istream &operator>>(istream &_in, vector<T> &_v) {
  for (auto &_i : _v) {
    _in >> _i;
  }
  return _in;
}
const long long MAXN = 3e5;
const long long INF = 1e12;
const long long MOD = 1e9 + 7;
mt19937 rnd(228);
class BProizvedeniyaStepeni {
 public:
  void solve(std::istream &in, std::ostream &out) {
    long long n, k;
    in >> n >> k;
    vector<long long> prost;
    for (long long i = 2; i < MAXN; i++) {
      bool prav = 1;
      for (auto v : prost) {
        if (v * v > i) {
          break;
        }
        if (i % v == 0) {
          prav = 0;
          break;
        }
      }
      if (prav) {
        prost.push_back(i);
      }
    }
    vector<long long> leks(k);
    for (auto &v : leks) {
      v = rnd() % 300;
    }
    leks[0] = 0;
    map<long long, long long> sex;
    set<long long> sexx;
    vector<long long> a(n);
    in >> a;
    map<long long, long long> keks;
    long long ans = 0;
    for (auto v : a) {
      map<long long, long long> meks;
      for (long long i = 0; i < ((long long)prost.size()); i++) {
        if (prost[i] * prost[i] > v) {
          break;
        }
        while (v % prost[i] == 0) {
          meks[prost[i]]++;
          v /= prost[i];
        }
      }
      if (v > 1) {
        meks[v]++;
      }
      long long sums = 0;
      long long sums1 = 0;
      for (auto v : meks) {
        if (sex.find(v.first) == sex.end()) {
          long long vv = rnd() % INF;
          while (sexx.find(vv) != sexx.end()) {
            vv = rnd() % INF;
          }
          sexx.insert(vv);
          sex[v.first] = vv;
        }
        sums += leks[(v.second % k)] * sex[v.first];
        sums1 += leks[((k - (v.second % k)) % k)] * sex[v.first];
      }
      ans += keks[sums1];
      keks[sums]++;
    }
    out << ans;
  }
};
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  BProizvedeniyaStepeni solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}
