#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010, mod = 1000000007;
inline long long read() {
  char ch = getchar();
  long long x = 0, f = 0;
  while (ch < '0' || ch > '9') f |= ch == '-', ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return f ? -x : x;
}
int x, num[maxn], len, ans = 1;
long long n;
int calc(int x) {
  int ans = 0;
  long long pr = x;
  while (true) {
    ans = (ans + n / pr) % (mod - 1);
    long long pre = pr;
    pr *= x;
    if (pr / pre != x || pr > n) break;
  }
  return ans;
}
int qpow(int a, int b) {
  int ans = 1;
  for (; b; b >>= 1, a = 1ll * a * a % mod)
    if (b & 1) ans = 1ll * ans * a % mod;
  return ans;
}
int main() {
  x = read();
  n = read();
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0) {
      num[++len] = i;
      while (x % i == 0) x /= i;
    }
  if (x > 1) num[++len] = x;
  for (int i = (1); i <= (len); i++) {
    int x = num[i];
    ans = 1ll * ans * qpow(x, calc(x)) % mod;
  }
  printf("%d\n", ans);
}
