#include <bits/stdc++.h>
void err() { std::cout << std::endl; }
template <typename T, typename... Args>
void err(T a, Args... args) {
  std::cout << a << ' ';
  err(args...);
}
using namespace std;
const long long mod = 1e9 + 7;
const int maxn = 2e5 + 22;
long long x, n, ans = 1;
vector<long long> v;
long long st[1000], as[1000];
long long poww(long long a, long long b) {
  long long ret = 1, base = a % mod;
  while (b) {
    if (b & 1 != 0) ret = (ret * base) % mod;
    base = (base * base) % mod;
    b >>= 1;
  }
  return ret;
}
int main() {
  scanf("%lld%lld", &x, &n);
  long long xx = x;
  for (long long i = 2; i * i <= x; i++) {
    if (xx % i == 0) {
      v.push_back(i);
      while (xx % i == 0) xx /= i;
    }
  }
  if (xx > 1) v.push_back(xx);
  for (long long i = 0; i < v.size(); i++) {
    long long tp = v[i];
    long double t = v[i], a = n;
    while (t <= a) {
      ans = ans * poww(v[i], a / tp) % mod;
      t *= (long double)v[i];
      tp *= v[i];
    }
  }
  printf("%lld", ans);
  return 0;
}
