#include <bits/stdc++.h>
using namespace std;
long long M = 1000000000 + 7;
long long power(long long x, long long n) {
  long long result = 1;
  while (n > 0) {
    if (n % 2 == 1) result = (result * x) % M;
    x = (x * x) % M;
    n = n / 2;
  }
  return result;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, x;
  cin >> x >> n;
  vector<long long> prime;
  long long tx = x;
  long long div = 2;
  for (long long i = 2; i * i <= x; i++) {
    long long temptx = tx;
    while (tx % div == 0) {
      tx /= div;
    }
    if (tx != temptx) prime.push_back(div);
    div++;
  }
  if (tx >= 2) prime.push_back(tx);
  long long ans = 1;
  for (long long p : prime) {
    long long i = 1;
    long long sum = 0;
    long long ratio = n / p;
    i = 2;
    while (ratio != 0) {
      ans *= power(p, ratio);
      ans %= M;
      ratio /= p;
    }
  }
  cout << ans;
  return 0;
}
