#include <bits/stdc++.h>
using namespace std;
const long long Mod = 1e9 + 7;
long long qpow(long long x, long long q) {
  long long ans = 1;
  while (q) {
    if (q & 1) ans = ans * x % Mod;
    q >>= 1;
    x = (x * x) % Mod;
  }
  return ans % Mod;
}
long long x, n;
int main() {
  cin >> x >> n;
  vector<int> a;
  for (long long i = 2; i <= sqrt(x); i++) {
    if (x % i) continue;
    a.push_back(i);
    while (x % i == 0) x /= i;
  }
  if (x != 1) a.push_back(x);
  long long ans = 1;
  for (int i = 0; i < a.size(); i++) {
    long long now = n, tot = 0;
    while (now) {
      tot += now / a[i];
      now /= a[i];
    }
    ans = (ans * qpow(a[i], tot) % Mod) % Mod;
  }
  cout << ans << endl;
  return 0;
}
