#include <bits/stdc++.h>
using namespace std;
template <typename T>
T pow(T x, T d, T p) {
  T res(1);
  for (T i(1); i <= d; i <<= 1, x = (x * x) % p)
    if (d & i) res = (res * x) % p;
  return res;
}
int main() {
  long long x, n;
  scanf("%lld %lld", &x, &n);
  vector<int> primes;
  for (int p = 2; p * p <= x; ++p) {
    if (x % p == 0) {
      primes.push_back(p);
      while (x % p == 0) x /= p;
    }
  }
  if (x > 1) primes.push_back(x);
  const int P = 1000000007;
  long long res = 1;
  for (int p : primes) {
    long long d = 0;
    for (long long m = n / p; m > 0; m /= p) d += m;
    res = (res * pow<long long>(p, d, P)) % P;
  }
  printf("%lld\n", res);
}
