#include <bits/stdc++.h>
using namespace std;
long long expo(long long base, long long exponent, long long mod) {
  long long ans = 1;
  while (exponent != 0) {
    if (exponent & 1) ans = (1LL * ans * base) % mod;
    base = (1LL * base * base) % mod;
    exponent >>= 1;
  }
  return ans % mod;
}
signed main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long x, n;
  cin >> x >> n;
  vector<long long> primespos;
  long long z = x;
  for (long long i = 2; i * i <= z; i++) {
    if (z % i == 0) primespos.push_back(i);
    while (z % i == 0) z = z / i;
  }
  if (z > 1) primespos.push_back(z);
  long long ans = 1;
  for (__typeof((long long)primespos.size()) i =
           (0) - ((0) > ((long long)primespos.size()));
       i !=
       ((long long)primespos.size()) - ((0) > ((long long)primespos.size()));
       i += 1 - 2 * ((0) > ((long long)primespos.size()))) {
    long long numb = n;
    long long sum = 0;
    while (numb > 0) {
      sum += numb / primespos[i];
      numb = numb / primespos[i];
    }
    ans = ans * expo(primespos[i], sum, 1000000007) % 1000000007;
  }
  cout << ans << '\n';
}
