#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 200;
const int mod = 1e9 + 7;
vector<unsigned long long> f;
unsigned long long pow_mod(unsigned long long a, unsigned long long n,
                           unsigned long long m) {
  unsigned long long ans = 1;
  while (n) {
    if (n & 1) {
      ans = (ans * a) % m;
    }
    a = (a * a) % m;
    n >>= 1;
  }
  return ans;
}
int main() {
  unsigned long long x, n;
  cin >> x >> n;
  for (unsigned long long i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      f.push_back(i);
      while (x % i == 0) x /= i;
    }
  }
  if (x != 1) f.push_back(x);
  unsigned long long ans = 1;
  int len = f.size();
  for (int i = 0; i < len; i++) {
    unsigned long long k = f[i];
    unsigned long long cur = 0;
    for (unsigned long long j = k; j <= n; j *= k) {
      cur += n / j;
      if (j > n / k) break;
    }
    ans = ans * pow_mod(k, cur, mod);
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}
