#include <bits/stdc++.h>
using namespace std;
long long first, n, ans, i, mod = 1e9 + 7;
vector<long long> pr;
long long pw(long long p, long long n) {
  if (n == 1) return p;
  long long res = pw(p, n / 2);
  return n & 1 ? res * res % mod * p % mod : res * res % mod;
}
int main() {
  cin >> first >> n;
  for (int i = 2; i <= 32000; ++i)
    if (first % i == 0) {
      pr.push_back(i);
      while (first % i == 0) first /= i;
    }
  if (first > 1) pr.push_back(first);
  ans = 1;
  for (long long p : pr) {
    for (i = p; i <= n; i *= p) {
      ans = ans * pw(p, n / i) % mod;
      if (i > n / p) break;
    }
  }
  cout << ans;
}
