#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
long long find(long long p, long long n) {
  if (p == 1) return 1LL;
  long long res = 0;
  while (n > 0) {
    n /= p;
    res += n;
  }
  return res;
}
long long pwr(long long a, long long b) {
  if (b == 1) return a;
  if (b == 0) return 1LL;
  long long sub = pwr(a, b / 2);
  if (b % 2) return (((sub * sub) % MOD) * a) % MOD;
  return (sub * sub) % MOD;
}
signed main() {
  ios_base::sync_with_stdio(false);
  long long xcp, n;
  cin >> xcp >> n;
  long long res = 1;
  for (long long i = 2; i * i <= xcp; i++) {
    if (xcp % i == 0) {
      long long t = find(i, n);
      res = (res * pwr(i, t)) % MOD;
      while (!(xcp % i)) xcp /= i;
    }
  }
  res = (res * pwr(xcp, find(xcp, n))) % MOD;
  cout << res;
  return 0;
}
