#include <bits/stdc++.h>
using namespace std;
namespace LYYY {
int read() {
  int s = 0;
  char c = getchar();
  int f = 1;
  while (c < 48 || c > 57) {
    if (c == 45) f = -1;
    c = getchar();
  }
  while (c >= 48 && c <= 57) s = (s << 3) + (s << 1) + (c ^ 48), c = getchar();
  return s * f;
}
long long readl() {
  long long s = 0;
  char c = getchar();
  int f = 1;
  while (c < 48 || c > 57) {
    if (c == 45) f = -1;
    c = getchar();
  }
  while (c >= 48 && c <= 57) s = (s << 3) + (s << 1) + (c ^ 48), c = getchar();
  return s * f;
}
void write(int x) {
  if (x >= 10) write(x / 10);
  putchar(x % 10 + 48);
}
void W(int x) {
  if (x < 0) x = -x, putchar(45);
  write(x);
}
void writel(long long x) {
  if (x >= 10) write(x / 10);
  putchar(x % 10 + 48);
}
void Wl(long long x) {
  if (x < 0) x = -x, putchar(45);
  write(x);
}
}  // namespace LYYY
using namespace LYYY;
const int mod = 1000 * 1000 * 1000 + 7;
int mul(int x, long long k) {
  long long ans = 1, mid = x;
  while (k) {
    if (k & 1) ans = ans * mid % mod;
    mid = mid * mid % mod;
    k >>= 1;
  }
  return ans;
}
int Get(long long n, int x) {
  if (n < x) return 1;
  return (long long)mul(x, n / x) * Get(n / x, x) % mod;
}
int main() {
  int x = read();
  long long n = readl(), ans = 1;
  for (int i = 2; i * i <= x; ++i)
    if (x % i == 0) {
      ans = ans * Get(n, i) % mod;
      while (x % i == 0) x /= i;
    }
  if (x > 1) ans = ans * Get(n, x) % mod;
  writel(ans);
  return 0;
}
