#include <bits/stdc++.h>
using namespace std;
long long int expo(long long int base, long long int exponent,
                   long long int mod) {
  long long int ans = 1;
  while (exponent != 0) {
    if (exponent & 1) ans = (1LL * ans * base) % mod;
    base = (1LL * base * base) % mod;
    exponent >>= 1;
  }
  return ans % mod;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  while (TESTS--) {
    long long int x, n;
    cin >> x >> n;
    long long int sx = sqrt(x) + 10;
    map<long long int, long long int> ma;
    for (long long int i = 2; i <= sx; i++) {
      while (x % i == 0) {
        x = x / i;
        ma[i]++;
      }
    }
    if (x != 1) ma[x]++;
    vector<long long int> v;
    for (auto i : ma) v.push_back(i.first);
    long long int ans = 1;
    for (auto i : v) {
      long long int p = i;
      long long int e = 0;
      long long int nn = n;
      for (long long int j = 1; true; j++) {
        e += nn / p;
        e = e % (1000000007 - 1);
        nn = nn / p;
        if (nn == 0) break;
      }
      long long int tmp = expo(i, e % (1000000007 - 1), 1000000007);
      ans = (ans * tmp) % 1000000007;
    }
    cout << ans;
  }
  return 0;
}
