#include <bits/stdc++.h>
using namespace std;
int mod = 1e9 + 7;
long long n;
long long fmp(long long b, long long p) {
  if (p == 0) return 1;
  long long a = fmp(b, p / 2);
  long long res = (a * a) % mod;
  if (p % 2) {
    return (res * b) % mod;
  }
  return res;
}
long long pgn(int p) {
  long long x = p, cnt = n / p;
  while (x <= n / p) {
    x *= p;
    cnt += n / x;
  }
  return fmp(p, cnt);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int x;
  cin >> x >> n;
  int mp = sqrt(x) + 1;
  long long ret = 1;
  for (int i = 2; i * i <= x && x > 1; i++) {
    if (x % i == 0) {
      while (x % i == 0) x /= i;
      ret = (ret * pgn(i)) % mod;
    }
  }
  if (x != 1) ret = (ret * pgn(x)) % mod;
  cout << ret;
  return 0;
}
