#include <bits/stdc++.h>
const long long MOD = 1e9 + 7;
using namespace std;
long long pow_mod(long long a, long long k) {
  long long int ans = 1;
  a %= MOD;
  while (k) {
    if (k % 2) ans *= a;
    a = (a * a) % MOD;
    k /= 2;
    ans %= MOD;
  }
  return ans;
}
int main() {
  long long x, n;
  long long ans = 1;
  cin >> x >> n;
  long long sq = ceil(sqrt(x));
  for (int i = 2; i <= sq; i++) {
    if (x % i == 0) {
      while (x % i == 0) x = x / i;
      sq = ceil(sqrt(x));
      long long tot = 0;
      long long now = n;
      while (now) {
        tot += now / i;
        now /= i;
      }
      ans = (ans * pow_mod(i, tot)) % MOD;
    }
  }
  if (x != 1) {
    long long tot = 0;
    long long now = n;
    while (now) {
      tot += now / x;
      now /= x;
    }
    ans = (ans * pow_mod(x, tot)) % MOD;
  }
  cout << ans % MOD;
}
