#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;
const long long int inf = 1e18 + 5;
set<long long int> s;
void primeFactors(long long int n) {
  while (n % 2 == 0) {
    s.insert(2);
    n = n / 2;
  }
  for (long long int i = 3; i <= sqrt(n); i = i + 2) {
    while (n % i == 0) {
      s.insert(i);
      n = n / i;
    }
  }
  if (n > 2) s.insert(n);
}
long long int cal(long long int N, long long int power, long long int MOD) {
  if (N == 0 || N == 1) return N % MOD;
  if (power == 0) return 1;
  if (MOD == 1) return 0;
  long long int ans = 1;
  while (power) {
    if (power % 2) {
      ans = (ans * N) % MOD;
    }
    N = (N * N) % MOD;
    power /= 2;
  }
  return ans;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int x, n;
  cin >> x >> n;
  primeFactors(x);
  vector<long long int> v((s).begin(), (s).end());
  long long int ans = 1;
  for (long long int i = 0; i < v.size(); i++) {
    long long int prim = v[i];
    long long int num = n;
    long long int cnt = 0;
    while (num != 0) {
      cnt += num / prim;
      num /= prim;
    }
    ans *= cal(prim, cnt, mod);
    ans %= mod;
  }
  cout << ans << '\n';
}
