#include <bits/stdc++.h>
using namespace std;
long long x, n;
const long long mod = 1000000007;
long long mull(long long a, long long b) {
  long long res = 0;
  while (b) {
    if (b & 1) res = (res + a) % mod;
    b = b >> 1;
    a = (a + a) % mod;
  }
  return res;
}
long long fast(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = mull(res, a);
    b = b >> 1;
    a = mull(a, a);
  }
  return res;
}
void input() { cin >> x >> n; }
void solve() {
  vector<long long> pri;
  for (long long i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      pri.push_back(i);
      while (x % i == 0) {
        x /= i;
      }
    }
  }
  if (x != 1) {
    pri.push_back(x);
  }
  long long ans = 1;
  for (auto z : pri) {
    long long mul = 1;
    long long xx = 0;
    while (mul <= n / z) {
      mul *= z;
      xx = (xx + (n / mul));
    }
    ans = mull(ans, fast(z, xx)) % mod;
  }
  cout << ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  while (t--) input(), solve();
  return 0;
}
