#include <bits/stdc++.h>
using namespace std;
const unsigned long long MOD = 1e9 + 7;
int mul(int a, int b) { return (long long)a * b % MOD; }
int mpow(int a, unsigned long long n) {
  int res = 1;
  for (; n > 0; n >>= 1) {
    if (n & 1) res = mul(res, a);
    a = mul(a, a);
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  unsigned long long x, n;
  cin >> x >> n;
  vector<int> primes;
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      primes.push_back(i);
      while (x % i == 0) {
        x /= i;
      }
    }
  }
  if (x > 1) {
    primes.push_back(x);
  }
  int ans = 1;
  for (auto p : primes) {
    cerr << p << '\n';
    unsigned long long aux = n;
    int power = 0;
    vector<pair<int, unsigned long long>> cnts;
    while (aux >= p) {
      unsigned long long cnt = aux / p;
      power++;
      cnts.push_back({power, cnt});
      aux /= p;
    }
    unsigned long long sum = 0;
    for (int i = cnts.size() - 1; i >= 0; i--) {
      unsigned long long tot = cnts[i].second - sum;
      cerr << tot << '\n';
      ans = mul(ans, mpow(mpow(p, cnts[i].first), tot));
      sum = cnts[i].second;
    }
  }
  cout << ans << '\n';
}
