#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int maxn = 1e5;
bool sieve[maxn + 5];
void gen() {
  for (int i = 0; i <= maxn; i++) sieve[i] = 1;
  sieve[0] = 0;
  sieve[1] = 0;
  for (int i = 2; i <= maxn; i++) {
    if (!sieve[i]) continue;
    for (int j = 2; i * j <= maxn; j++) sieve[i * j] = 0;
  }
}
long long mul(long long a, long long b, long long c) {
  long long ans = 0;
  while (b > 0) {
    if (b & 1) ans = (ans + a) % c;
    a = (a + a) % c;
    b >>= 1;
  }
  return ans;
}
long long ex(long long a, long long b, long long c) {
  long long ans = 1;
  while (b > 0) {
    if (b & 1) ans = mul(ans, a, c);
    a = mul(a, a, c);
    b >>= 1;
  }
  return ans;
}
int main() {
  gen();
  long long x, n;
  scanf("%lld%lld", &x, &n);
  vector<int> p;
  long long temp = x;
  for (int i = 2; i * i <= temp; i++) {
    if (x % i == 0 && sieve[i]) {
      p.push_back(i);
      while (x % i == 0) x /= i;
    }
  }
  if (x != 1) p.push_back(x);
  long long ans = 1;
  for (int i = 0; i < (int)p.size(); i++) {
    long long cont = 0;
    temp = n;
    while (temp) {
      temp /= p[i];
      cont += temp;
    }
    ans = mul(ans, ex((long long)p[i], cont, mod), mod);
  }
  cout << ans;
  return 0;
}
