#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long long x, n, ans = 1;
long long fp(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = ret * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return ret % mod;
}
int main() {
  scanf("%lld%lld", &x, &n);
  long long t = x;
  for (int i = 2; i * i <= x; i++) {
    if (t % i == 0) {
      while (t % i == 0) t /= i;
      long long cnt = 0;
      for (long long j = n; j; j /= i) cnt = (cnt + j / i) % (mod - 1);
      ans = ans * fp(i, cnt) % mod;
    }
  }
  if (t > 1) {
    long long cnt = 0;
    for (long long i = n; i; i /= t) cnt = (cnt + i / t) % (mod - 1);
    ans = ans * fp(t, cnt) % mod;
  }
  cout << ans;
  return 0;
}
