#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long long qpow(long long a, long long x, long long mo) {
  int res = 1;
  while (x) {
    if (x & 1) res = 1ll * res * a % mo;
    a = 1ll * a * a % mo;
    x >>= 1;
  }
  return res;
}
int x;
vector<int> g;
long long n;
int main() {
  scanf("%d%lld", &x, &n);
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0) {
      g.push_back(i);
      while (x % i == 0) x /= i;
    }
  if (x > 1) g.push_back(x);
  long long ans = 1;
  for (int i = 0; i < g.size(); i++) {
    long long p = g[i];
    long long k = n;
    while (p <= k) {
      ans = 1ll * ans * qpow(g[i], k / p, mod) % mod;
      k /= p;
    }
  }
  cout << ans << endl;
}
