#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000055;
const int inf = 0x3f3f3f3f;
const double pi = acos(-1.0);
const int mod = 1e9 + 7;
long long pow_mod(long long a, long long b) {
  long long ans = 1 % mod;
  for (; b; b >>= 1) {
    if (b & 1) ans = (long long)ans * a % mod;
    a = (long long)a * a % mod;
  }
  return ans;
}
long long x, n;
long long p[MAXN], c[MAXN];
int cnt;
void divide(long long n) {
  cnt = 0;
  int lim = sqrt(n);
  for (int i = 2; i <= lim; ++i) {
    if (n % i == 0) {
      p[++cnt] = i, c[cnt] = 0;
      while (n % i == 0) n /= i, c[cnt]++;
    }
  }
  if (n > 1) p[++cnt] = n, c[cnt] = 1;
}
int main() {
  cin >> x >> n;
  divide(x);
  long long ans = 1;
  for (int i = 1; i <= cnt; ++i) {
    long long k = 1, tmp = 0;
    while ((long long)(n / (long long)pow(p[i], k))) {
      tmp += (long long)(n / (long long)pow(p[i], k));
      k++;
    }
    ans = ans * pow_mod(p[i], tmp) % mod;
  }
  cout << ans << endl;
  return 0;
}
