#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const long long MOD = 1e9 + 7;
const int inf = 1e9 + 1;
const double eps = 1e-7;
const long long OO = 1e18;
vector<long long> factorize(long long n) {
  vector<long long> v;
  for (int i = 2; i <= n / i; i += 1 + (i & 1)) {
    if (n % i == 0) {
      while (n % i == 0) n /= i;
      v.push_back(i);
    }
  }
  if (n != 1) v.push_back(n);
  return v;
}
long long calc(long long cur, long long n) {
  long long tmpCur = cur;
  long long power = 0;
  while (tmpCur <= n) {
    power = (power + n / tmpCur) % (MOD - 1);
    if (tmpCur > n / cur) break;
    tmpCur *= cur;
  }
  return power;
}
long long fp(long long base, long long exp) {
  long long ans = 1;
  while (exp) {
    if (exp & 1) ans = ans * base % MOD;
    base = base * base % MOD;
    exp >>= 1;
  }
  return ans;
}
int main() {
  long long x, n, ans = 1;
  cin >> x >> n;
  auto p = factorize(x);
  for (auto cur : p) ans = ans * fp(cur, calc(cur, n)) % MOD;
  cout << ans;
  return 0;
}
