#include <bits/stdc++.h>
using namespace std;
const unsigned long long HA = 1e9 + 7;
unsigned long long x, n;
unsigned long long fastpow(const unsigned long long& a, unsigned long long b) {
  if (b == 0) {
    return 1;
  }
  unsigned long long tmp = fastpow(a, b / 2);
  if (b & 1) {
    return (tmp * tmp % HA) * a % HA;
  } else {
    return tmp * tmp % HA;
  }
}
int main() {
  cin >> x >> n;
  unsigned long long ans = 1;
  vector<unsigned long long> primes;
  unsigned long long bakx = x;
  for (unsigned long long i = 2; i * i <= bakx; ++i) {
    if (x % i == 0) {
      primes.push_back(i);
      while (x % i == 0) {
        x /= i;
      }
    }
  }
  if (x != 1) {
    primes.push_back(x);
  }
  for (unsigned long long i : primes) {
    unsigned long long cnt = 0;
    unsigned long long tmp = n;
    while (tmp) {
      cnt += tmp / i;
      cnt %= (HA - 1);
      tmp /= i;
    }
    ans = ans * fastpow(i, cnt) % HA;
  }
  cout << ans << endl;
  return 0;
}
