#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long SUM = 0, ff = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') ff = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    SUM = (SUM << 3) + (SUM << 1) + (ch ^ 48);
    ch = getchar();
  }
  return SUM * ff;
}
const int N = 200010;
const long long mod = 1e9 + 7;
inline long long qpow(long long a, long long p) {
  long long res = 1;
  while (p) {
    if (p & 1) res = res * a % mod;
    a = a * a % mod;
    p >>= 1;
  }
  return res;
}
long long ans = 1;
inline void calc(long long x, long long n) {
  while (n) {
    ans = ans * qpow(x, n / x) % mod;
    n /= x;
  }
}
int cnt;
long long prime[N];
inline void sieve(long long x) {
  for (long long i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      prime[++cnt] = i;
      while (x % i == 0) x /= i;
    }
  }
  if (x > 1) prime[++cnt] = x;
}
int main() {
  long long x = read(), n = read();
  sieve(x);
  for (int i = 1; i <= cnt; i++) calc(prime[i], n);
  printf("%d\n", ans);
  return 0;
}
