#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long bpow(long long x, long long p) {
  long long res = 1;
  while (p) {
    if (p & 1) {
      res *= x;
      res %= MOD;
    }
    x *= x;
    x %= MOD;
    p >>= 1;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n, x;
  cin >> x >> n;
  vector<long long> divs;
  for (long long d = 2; x > 1 && d * d <= x; d++) {
    if (x % d == 0) {
      divs.push_back(d);
      while (x % d == 0) x /= d;
    }
  }
  if (x != 1) divs.push_back(x);
  long long ans = 1;
  for (long long div : divs) {
    long long pw = 0;
    for (long long cur = n / div; cur > 0; cur /= div) {
      pw += cur;
    }
    ans *= bpow(div, pw);
    ans %= MOD;
  }
  cout << ans;
}
