#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e6;
const int MOD = (int)(1e9) + 7;
int factor[N + 1];
int factorize(long long n) {
  int cnt = 0;
  for (int i = 2; i * i <= n; i += (1 + (1 & i))) {
    if (n % i == 0) factor[cnt++] = i;
    while (n % i == 0) n /= i;
  }
  if (n > 1) factor[cnt++] = n;
  return cnt;
}
long long power(long long b, long long p) {
  long long ans = 1;
  while (p) {
    if (p & 1) ans = (ans * b) % MOD;
    b = (b * b) % MOD;
    p >>= 1;
  }
  return ans;
}
int main() {
  long long x, n, temp, ans = 1, p = 0, f;
  cin >> x >> n;
  int len = factorize(x);
  for (int i = 0; i < len; i++) {
    f = factor[i];
    temp = n, p = 0;
    while (temp /= f) p += temp;
    ans = (ans * power(f, p)) % MOD;
  }
  cout << ans << endl;
  return 0;
}
