#include <bits/stdc++.h>
using namespace std;
long long int x, n, k, prod = 1, fac, powr, tprod, i;
long long int power(long long int base, long long int exponent) {
  if (exponent == 0) return 1;
  if (exponent == 1) return base % 1000000007;
  if (exponent % 2 == 0) {
    return power((base * base) % 1000000007, exponent / 2);
  }
  return (power(base * base % 1000000007, exponent / 2) * base) % 1000000007;
}
int main() {
  scanf("%lld%lld", &x, &n);
  fac = 2;
  while (fac <= sqrt(x)) {
    if (x % fac == 0) {
      while (x % fac == 0) {
        x /= fac;
      }
      tprod = 1;
      while (tprod <= n / fac) {
        tprod = (tprod * fac);
        prod = (prod *
                power(tprod % 1000000007, n / tprod - (n / tprod) / ((fac)))) %
               1000000007;
      }
    }
    fac++;
  }
  if (x > 1) {
    tprod = 1;
    while (tprod <= n / x) {
      tprod = (tprod * x);
      prod =
          (prod * power(tprod % 1000000007, n / tprod - (n / tprod) / ((x)))) %
          1000000007;
    }
  }
  printf("%lld\n", prod);
  return 0;
}
