#include <bits/stdc++.h>
using namespace std;
long long binpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % m;
    a = (a * a) % m;
    b >>= 1;
  }
  return res;
}
void solve() {
  long long int x, n, y, z, ans = 1;
  cin >> x >> n;
  vector<long long int> v;
  y = x;
  for (long long int i = 2; i * i <= x; i++) {
    if (y % i == 0) {
      v.push_back(i);
      while (y % i == 0) y /= i;
    }
  }
  if (y != 1) v.push_back(y);
  for (long long int i = 0; i < v.size(); i++) {
    long long int a = v[i], b = 0;
    while (a <= n) {
      z = (n / a);
      b += z;
      if (z < v[i]) break;
      a *= v[i];
    }
    ans = (ans * binpow(v[i], b, 1000000007)) % 1000000007;
  }
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
