#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b) {
  if (b == 0) return 1;
  if (b == 1) return a % 1000000007;
  long long temp = power(a, b / 2) % 1000000007;
  temp = (temp * temp) % 1000000007;
  if (b % 2 == 0)
    return temp;
  else {
    return (a * temp) % 1000000007;
  }
}
long long intlog(long long base, long long x) {
  return (long long)(log(x) / log(base));
}
int main() {
  long long x, n;
  cin >> x >> n;
  vector<long long> divisor;
  if (x % 2 == 0) {
    divisor.push_back(2);
    while (x % 2 == 0) {
      x /= 2;
    }
  }
  for (long long i = 3; i <= sqrt(x); i += 2) {
    if (x % i == 0) {
      divisor.push_back(i);
      while (x % i == 0) {
        x /= i;
      }
    }
  }
  if (x > 2) {
    divisor.push_back(x);
  }
  long long ans = 1;
  for (auto p : divisor) {
    long long sum = 0;
    long long val = n;
    long long digit = p;
    long long times = intlog(p, n);
    while ((val / digit) > 0 && (times--)) {
      sum += (val / digit);
      digit *= p;
    }
    if (digit == n) {
      sum += (val / digit);
    }
    ans = (ans * power(p, sum)) % 1000000007;
  }
  cout << ans << endl;
  return 0;
}
