#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long mul(long long a, long long b) {
  return ((a % mod) * (b % mod)) % mod;
}
long long binpow(long long a, long long n) {
  long long res = 1;
  while (n) {
    if (n & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    n >>= 1;
  }
  return res;
}
long long f(long long x, long long n) {
  long long res = 0;
  long long now = 1;
  while (n / x >= now) {
    res++;
    now *= x;
  }
  return res;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  long long x, n;
  cin >> x >> n;
  vector<long long> prime;
  for (int i = 2; 1LL * i * i <= x; i++) {
    if (x % i == 0) {
      while (x % i == 0) {
        x /= i;
      }
      prime.push_back(i);
    }
  }
  if (x != 1) {
    prime.push_back(x);
  }
  map<long long, long long> kek;
  long long ans = 1;
  for (auto i : prime) {
    long long now = 1, col = 0, del = 0;
    while (n / i >= now) {
      now *= i;
      del++;
      col++;
    }
    long long last = 0;
    while (now != 1) {
      ans = mul(ans, binpow(now, n / now - last));
      last += n / now - last;
      now /= i;
    }
  }
  cout << ans << "\n";
  return 0;
}
