#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
int prime[maxn / 10], tot;
bool isprime[maxn];
void Euler() {
  memset(isprime, true, sizeof isprime);
  isprime[0] = isprime[1] = false;
  tot = 0;
  for (int i = 2; i <= maxn; i++) {
    if (isprime[i]) prime[tot++] = i;
    for (int j = 0; j < tot && prime[j] <= maxn / i; j++) {
      isprime[i * prime[j]] = false;
      if (i % prime[j] == 0) break;
    }
  }
}
long long S(long long x, long long p) {
  if (x / p == 0) return 0;
  return (S(x / p, p) + (x / p) % (mod - 1)) % (mod - 1);
}
long long fast(long long x, long long y = mod - 2) {
  long long ans = 1;
  while (y) {
    if (y & 1) ans = ans * x % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
int main() {
  Euler();
  int x;
  long long n;
  cin >> x >> n;
  long long ans = 1;
  long long pn = n;
  long long k;
  for (int i = 0; i < tot; i++) {
    if (x % prime[i] == 0)
      k = S(n, prime[i]);
    else
      continue;
    ans = ans * fast(prime[i], k) % mod;
    while (x % prime[i] == 0) x /= prime[i];
  }
  if (x != 1) {
    k = S(n, x);
    ans = ans * fast(x, k) % mod;
  }
  cout << ans;
  return 0;
}
