#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
template <typename T>
T pow(T a, T b, long long m) {
  T ans = 1;
  while (b > 0) {
    if (b % 2 == 1) ans = (ans * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return ans % m;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  unsigned long long x, n;
  vector<unsigned long long> pr;
  cin >> x >> n;
  if (x % 2 == 0) pr.push_back(2);
  while (x % 2 == 0) x /= 2;
  for (unsigned long long i = 3; i * i <= x; i += 2) {
    if (x % i == 0) pr.push_back(i);
    while (x % i == 0) x /= i;
  }
  if (x > 2) pr.push_back(x);
  unsigned long long ans = 1;
  for (auto i : pr) {
    unsigned long long y = i;
    while (i <= n) {
      unsigned long long nd = (n / i);
      ans *= pow(y, nd, 1000000007);
      ans %= 1000000007;
      if (i > n / y) break;
      i *= y;
    }
  }
  cout << ans;
}
