#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long s = 0, w = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (isdigit(ch)) s = s * 10 + ch - '0', ch = getchar();
  return s * w;
}
inline void write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
const long long mod = 1e9 + 7;
long long x, n;
set<long long> second;
void fj() {
  for (long long i = 2; i * i <= x; ++i) {
    if (x % i == 0) second.insert(i);
    while (x % i == 0) {
      x /= i;
    }
  }
  if (x > 0) second.insert(x);
}
long long quick(long long a, long long b) {
  long long ans = 1;
  a %= mod;
  while (b) {
    if (b & 1) (ans *= a) %= mod;
    (a *= a) %= mod;
    b >>= 1;
  }
  return ans;
}
int main() {
  x = read();
  n = read();
  fj();
  long long ans = 1;
  for (auto it : second) {
    long long last = 0;
    long long cc = log(n * 1.0 + n - 1) / log(it * 1.0);
    long long now = 1;
    for (int i = 1; i <= cc; ++i) now *= it;
    for (long long i = cc; i >= 1; --i) {
      (ans *= quick(now, n / now - last)) %= mod;
      last = n / now;
      now /= it;
    }
  }
  write(ans);
  putchar('\n');
  return 0;
}
