#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 5;
const int mod = 1e9 + 7;
vector<int> v;
void div(long long n) {
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      v.push_back(i);
      while (n % i == 0) n /= i;
    }
  }
  if (n > 1) v.push_back(n);
}
long long qpow(long long a, long long k) {
  long long res = 1;
  while (k > 0) {
    if (k & 1) res = (res * a) % mod;
    k >>= 1;
    a = (a * a) % mod;
  }
  return res;
}
int main() {
  long long x, y;
  cin >> x >> y;
  div(x);
  long long res = 1;
  for (auto& v1 : v) {
    long long v2 = v1;
    while (v2 <= y) {
      long long temp1 = y / v2;
      res = (res * qpow(v1, temp1)) % mod;
      if (v2 * v1 < v2) {
        break;
      }
      v2 *= v1;
    }
  }
  cout << res << endl;
  return 0;
}
