#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a) % 1000000007;
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return res;
}
signed main() {
  std ::ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, x;
  cin >> n >> x;
  vector<long long> primes;
  long long p = n;
  for (long long i = 2; i * i <= p; i++) {
    if (p % i) continue;
    primes.push_back(i);
    while (p % i == 0) p /= i;
  }
  if (p > 1) primes.push_back(p);
  long long answer = 1;
  for (long long i = 0; i < primes.size(); i++) {
    long long prime = primes[i];
    long long cur = x;
    long long cnt = 0;
    while (cur) {
      cnt += (cur / prime);
      cur /= prime;
    }
    answer = (answer * power(prime, cnt)) % 1000000007;
  }
  cout << answer;
}
