#include <bits/stdc++.h>
using namespace std;
constexpr size_t kMod{1000000000 + 7};
constexpr size_t kMaxSieve{1000000};
long long binpow(long long numm, long long poww) {
  if (poww == 0) return 1;
  if (poww % 2 == 0) return binpow((numm * numm) % kMod, poww / 2);
  return (numm * binpow(numm, poww - 1)) % kMod;
}
long long f(long long n, long long p) {
  if (n < p) return 1;
  return (binpow(p, n / p) * f(n / p, p)) % kMod;
}
long long x;
unordered_set<long long> primes;
void precalc() {
  long long tx = x;
  for (long long i = 2; i * i <= tx; ++i) {
    if (tx % i != 0) continue;
    primes.insert(i);
    while (tx % i == 0) tx /= i;
  }
  if (tx > 1) primes.insert(tx);
}
bool is_prime(long long numm) { return primes.find(numm) != primes.end(); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> x >> n;
  precalc();
  long long ans = 1;
  for (long long i = 1; i * i <= x; ++i) {
    if (x % i != 0) continue;
    long long a = i;
    long long b = x / i;
    if (is_prime(a)) {
      ans = (ans * f(n, a)) % kMod;
    }
    if (a != b && is_prime(b)) {
      ans = (ans * f(n, b)) % kMod;
    }
  }
  cout << ans << endl;
  return 0;
}
