#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
int p[100000];
long long modpow(long long x, long long n) {
  long long res = 1;
  long long mul = x;
  while (n) {
    if (n % 2) res = res * mul % MOD;
    mul = mul * mul % MOD;
    n /= 2;
  }
  return res;
}
int main() {
  vector<long long> v;
  for (long long i = 2; i < 100000; i++) {
    if (p[i] == 0) {
      v.push_back(i);
      for (int j = 0; j < 100000; j += i) p[j] = 1;
    }
  }
  long long x, n;
  cin >> x >> n;
  vector<long long> w;
  for (long long q : v) {
    if (x % q == 0) w.push_back(q);
    while (x % q == 0) x /= q;
  }
  if (x != 1) w.push_back(x);
  long long ans = 1;
  for (long long q : w) {
    long long b = q;
    ans = (ans * modpow(q, n / q)) % MOD;
    while (n / b >= q) {
      b *= q;
      ans = (ans * modpow(q, n / b)) % MOD;
    }
  }
  cout << ans << endl;
}
