#include <bits/stdc++.h>
using namespace std;
bool CheckIfPrime(int x) {
  if (x == 1) return false;
  for (int y = 2; y * y <= x; y++) {
    if (x % y == 0) return false;
  }
  return true;
}
vector<int> GetPrimes(int x) {
  int y = x;
  vector<int> ret;
  for (int p = 1; p * p <= x; p++) {
    if (x % p == 0) {
      if (CheckIfPrime(p)) {
        ret.push_back(p);
      }
      if (p * p != x && CheckIfPrime(x / p)) {
        ret.push_back(x / p);
      }
    }
  }
  return ret;
}
long long g(long long x, long long p) {
  if (x % p != 0) return 1;
  long long ret = 1;
  while (x % p == 0) {
    x /= p;
    ret *= p;
  }
  return ret;
}
long long modpow(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a) % 1000000007;
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return res;
}
int main() {
  long long x, n;
  cin >> x >> n;
  vector<int> P = GetPrimes(x);
  long long ans = 1;
  for (long long p : P) {
    long long q = p;
    long long m = n;
    long long ct = 0;
    while (m) {
      ct += m / p;
      m /= p;
    }
    ans = ans * modpow(p, ct) % 1000000007;
  }
  cout << ans << endl;
}
