#include <bits/stdc++.h>
using namespace std;
long long int find_power(long long int n, long long int a) {
  long long int count = 0;
  long long int temp = a;
  while (temp <= n) {
    count += n / temp;
    n /= a;
  }
  return count;
}
long long int do_power(long long int count, long long int a) {
  long long int ans = 1, temp = 1;
  if (count == 1) {
    return a % 1000000007;
  } else if (count == 0)
    return 1;
  if (count % 2 == 0) {
    temp = do_power(count / 2, a);
    ans = (temp * temp) % 1000000007;
  } else {
    temp = do_power((count - 1) / 2, a);
    ans = (((temp * temp) % 1000000007) * (a % 1000000007)) % 1000000007;
  }
  return ans;
}
int main() {
  long long int x, n;
  cin >> x >> n;
  std::vector<int> v;
  if (x % 2 == 0) {
    v.push_back(2);
    while (x % 2 == 0) {
      x /= 2;
    }
  }
  long long int q = x;
  for (int i = 3; i <= sqrt(q); i += 2) {
    if (x % i == 0) {
      v.push_back(i);
      while (x % i == 0) {
        x /= i;
      }
    }
  }
  if (x != 1) {
    v.push_back(x);
  }
  long long int ans = 1;
  for (int i = 0; i < v.size(); i++) {
    long long int temp = find_power(n, v[i]);
    ans *= do_power(temp, v[i] % 1000000007);
    ans %= 1000000007;
  }
  cout << ans << endl;
}
