#include <bits/stdc++.h>
using namespace std;
int m, x, p[100005], h[100005], cnt;
long long n;
int ksm(int a, long long k) {
  if (!k) return 1;
  int p = ksm(a, k / 2);
  if (k & 1) return (long long)p * p % 1000000007 * a % 1000000007;
  return (long long)p * p % 1000000007;
}
int Getval(long long n, int x) {
  int ret = 1;
  while (n) {
    n /= x;
    ret = (long long)ret * ksm(x, n) % 1000000007;
  }
  return ret;
}
int main() {
  scanf("%d%I64d", &x, &n);
  int m = int(sqrt(x)) + 1, ans = 1;
  for (int i = 2; i <= m; i++) {
    if (x % i == 0) {
      while (x % i == 0) x /= i;
      ans = (long long)ans * Getval(n, i) % 1000000007;
    }
  }
  if (x > 1) ans = (long long)ans * Getval(n, x) % 1000000007;
  printf("%d\n", ans);
}
