#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
bool prime(long long x) {
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0) return false;
  return true;
}
long long binpow(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<int> pr;
  long long x, n;
  cin >> x >> n;
  if (x % 2 == 0) {
    while (x % 2 == 0) x /= 2;
    pr.push_back(2);
  }
  for (int i = 3; i * i <= x; i++) {
    if (x % i == 0) {
      pr.push_back(i);
      while (x % i == 0) x /= i;
    }
  }
  if (x > 1) pr.push_back(x);
  long long ans = 1;
  for (auto it : pr) {
    long long tmp = it;
    long long cnt = 0;
    long long po = 0;
    while (tmp <= n) {
      po++;
      cnt += (n / tmp);
      if (n / tmp < it) break;
      tmp *= it;
    }
    if (cnt == 0) continue;
    ans = ans * binpow(it, cnt) % mod;
  }
  cout << ans;
  return 0;
}
