#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long x, n;
  cin >> x >> n;
  set<long long> s;
  while (x % 2 == 0) {
    s.insert(2);
    x = x / 2;
  }
  for (long long i = 3; i <= sqrt(x); i = i + 2) {
    while (x % i == 0) {
      s.insert(i);
      x = x / i;
    }
  }
  if (x > 2) s.insert(x);
  vector<long long> v;
  for (auto it : s) v.push_back(it);
  long long ans = 1;
  for (long long i = 0; i < v.size(); i++) {
    long long tmp = n;
    long long p = 0;
    while (tmp) {
      p += tmp / v[i];
      tmp = tmp / v[i];
    }
    ans = (ans % 1000000007 * (power(v[i], p, 1000000007)) % 1000000007) %
          1000000007;
  }
  cout << ans << '\n';
  return 0;
}
