#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
long long inf = 1e18;
long long m_inf = INT_MIN;
long long expmod(long long a, long long b) {
  if (b == 1) return a;
  if (b == 0) return 1;
  long long m1 = expmod(a, b / 2) % mod;
  if (b % 2) return ((m1 * m1) % mod * a % mod) % mod;
  return (m1 * m1) % mod;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  std::cout.unsetf(std::ios::fixed);
  std::cout.precision(9);
  long long t = 1;
  while (t--) {
    long long x, n;
    cin >> x >> n;
    long long temp = x;
    vector<long long> p;
    for (long long i = 2; i * i <= x; i++) {
      if (temp % i == 0) {
        p.push_back(i);
        while (temp % i == 0) temp /= i;
      }
    }
    if (temp > 1) p.push_back(temp);
    long long ans = 1;
    for (long long i = 0; i < p.size(); i++) {
      long long count = 0;
      temp = n;
      while (temp > 0) {
        count += (temp / p[i]);
        temp /= p[i];
      }
      ans = (ans * expmod(p[i], count)) % mod;
    }
    cout << ans << '\n';
  }
}
