#include <bits/stdc++.h>
using namespace std;
long long int fexp(long long int a, long long int b) {
  b %= (1000000007 - 1);
  if (b == 0) return 1;
  a %= 1000000007;
  long long int small = fexp(a, b / 2);
  small %= 1000000007;
  small *= small;
  small %= 1000000007;
  if (b & 1) small *= a;
  small %= 1000000007;
  return small;
}
int main() {
  unsigned long long int X, x, n, ans = 1ull, N;
  cin >> x >> n;
  X = x;
  set<int> primes;
  if (x > 0 and !(x & 1)) {
    primes.insert(2);
    while (!(x & 1) and x > 0) x >>= 1;
  }
  int i = 3;
  while (i * i <= X) {
    if (!(x % i)) {
      primes.insert(i);
      while (x and !(x % i)) x /= i;
    }
    i += 2;
  }
  if (x > 1) primes.insert(x);
  x = X;
  N = n;
  long long int powerk, temp;
  for (auto a : primes) {
    powerk = a;
    temp = 0;
    n = N;
    while ((n / powerk)) temp += (n / powerk), n /= a;
    ans *= (fexp(a, temp) % 1000000007);
    ans %= 1000000007;
  }
  cout << ans << endl;
  return 0;
}
