#include <bits/stdc++.h>
using namespace std;
long long x, n;
vector<long long> v1;
const long long mod = 1e9 + 7;
long long ans = 1;
long long p[70];
long long len1;
long long quick_pow(long long a, long long b) {
  long long ans = 1;
  for (long long base = a % mod; b; b >>= 1, base = base * base % mod)
    if (b & 1) ans = ans * base % mod;
  return ans;
}
signed main() {
  scanf("%lld%lld", &x, &n);
  for (long long i = 2; i <= sqrt(x); i++) {
    if (x % i == 0) v1.push_back(i);
    while (x % i == 0) {
      x /= i;
    }
  }
  if (x) v1.push_back(x);
  len1 = v1.size();
  for (long long i = 0; i < len1; i++) {
    memset(p, 0, sizeof(p));
    p[0] = 1;
    long long j;
    for (j = 1; j <= 65; j++) {
      if (n / v1[i] < p[j - 1]) {
        break;
      }
      p[j] = p[j - 1] * v1[i];
      if (j == 1) continue;
      ans = ans * quick_pow(p[j - 1], n / p[j - 1] - n / p[j]) % mod;
    }
    j--;
    ans = ans * quick_pow(p[j], n / p[j]) % mod;
  }
  cout << ans << endl;
  return 0;
}
