#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long po(long long x, long long a) {
  long long ans = 1;
  long long now = x;
  while (a) {
    if (a & 1) ans = (ans * now) % mod;
    now = (now * now) % mod;
    a >>= 1;
  }
  return ans;
}
int main() {
  long long x, n;
  scanf("%lld%lld", &x, &n);
  vector<long long> v;
  for (long long i = 2; i * i <= x; i++)
    if (x % i == 0) {
      while (x % i == 0) x /= i;
      v.push_back(i);
    }
  if (x > 1) v.push_back(x);
  long long ans = 1;
  for (auto e : v) {
    long long tt = n;
    long long p = 0;
    while (tt) {
      tt /= e;
      p += tt;
    }
    ans = (ans * po(e, p)) % mod;
  }
  printf("%lld\n", ans);
  return 0;
}
