#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
clock_t start_time, end_time;
void open() {
  ((void)0);
  ((void)0);
  ((void)0);
  ((void)0);
}
void close() {
  ((void)0);
  ((void)0);
}
const int MAX = 1e5 + 1;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long LL_INF = 0x3f3f3f3f3f3f3f3fLL;
const double PI = acos(-1);
const long double ERR = 1e-10;
const int move_r[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int move_c[] = {0, -1, 0, 1, -1, 1, -1, 1};
long long _pow(long long base, long long exp) {
  long long ret = 1;
  while (exp) {
    if (exp % 2LL) ret = ret * base % MOD;
    base = base * base % MOD;
    exp /= 2LL;
  }
  return ret;
}
long long count(long long val, long long p) {
  long long cnt = 0;
  while (val) {
    cnt += val / p;
    val /= p;
  }
  return cnt;
}
int main(int argc, char *argv[]) {
  open();
  long long x, n;
  scanf("%lld %lld", &x, &n);
  long long ans = 1;
  for (long long i = 2; i * i <= x; ++i) {
    if (x % i == 0) {
      ans = ans * _pow(i, count(n, i)) % MOD;
      while (x % i == 0) x /= i;
    }
  }
  if (x > 1) ans = ans * _pow(x, count(n, x)) % MOD;
  printf("%lld\n", ans);
  close();
  return 0;
}
