#include <bits/stdc++.h>
using namespace std;
unsigned long long read() {
  unsigned long long ret = 0, f = 1;
  char c = getchar();
  while (c > '9' || c < '0') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    ret = (ret << 1) + (ret << 3) + c - 48;
    c = getchar();
  }
  return ret * f;
}
const int maxn = 1e6;
const unsigned long long mod = 1e9 + 7;
int a[maxn], cnt;
bool b[maxn] = {1, 1};
unsigned long long pow(unsigned long long a, unsigned long long n) {
  unsigned long long ans = 1;
  while (n) {
    if (n & 1) ans = ans * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return ans;
}
unsigned long long get(unsigned long long n, unsigned long long j) {
  unsigned long long ans = 1, x = 0;
  x = n / j;
  while (x) {
    ans = ans * pow(j, x) % mod;
    x /= j;
  }
  return ans;
}
int main() {
  unsigned long long x = read(), n = read();
  unsigned long long ans = 1;
  for (unsigned long long j = 2; j * j <= x; j++) {
    if (x % j == 0) {
      ans = ans * get(n, j) % mod;
      while (x % j == 0) x /= j;
    }
  }
  if (x > 1) ans = ans * get(n, x) % mod;
  cout << ans << endl;
}
