#include <bits/stdc++.h>
using namespace std;
long long N = 1e9 + 7;
long long power(long long x, long long y) {
  long long temp;
  if (y == 0) return 1;
  temp = (power(x, y / 2)) % N;
  if (y % 2 == 0)
    return ((temp * temp) % N);
  else
    return (((x * temp) % N) * temp) % N;
}
bool isPrime(long long n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
       << "ms\n";
  long long x, n, i;
  cin >> x >> n;
  vector<long long> v;
  for (i = 1; i * i <= x; i++) {
    if (x % i == 0) {
      if (isPrime(i)) v.push_back(i);
      if ((i * i != x) && isPrime(x / i)) v.push_back(x / i);
    }
  }
  long long m = v.size(), ans = 1, k;
  for (i = 0; i < m; i++) {
    k = n / v[i];
    while (k > 0) {
      ans *= power(v[i], k);
      ans %= N;
      k /= v[i];
    }
  }
  cout << ans;
  return 0;
}
