#include <bits/stdc++.h>
using namespace std;
template <typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) {
  return os << '(' << pai.first << ' ' << pai.second << ')';
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
  os << '[';
  for (auto p : v) os << p << ",";
  os << "]";
  return os;
}
template <typename T, typename V>
ostream &operator<<(ostream &os, const set<T, V> v) {
  os << "{";
  for (auto p : v) os << p << ",";
  os << "}";
  return os;
}
template <typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> v) {
  os << "{";
  for (auto p : v) os << p << ",";
  os << "}";
  return os;
}
template <typename T>
void get_max(T &a, T b) {
  a = max(a, b);
}
template <typename T>
void get_min(T &a, T b) {
  a = min(a, b);
}
const long long MOD = 1e9 + 7;
int A;
long long B;
long long mpow(long long a, long long b) {
  long long res = 1;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % MOD;
    a = a * a % MOD;
  }
  return res;
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> A >> B;
  vector<int> fac;
  for (int i = 2; i * i <= A; i++) {
    if (A % i == 0) {
      fac.push_back(i);
      while (A % i == 0) A /= i;
    }
  }
  if (A > 1) fac.push_back(A);
  0;
  long long res = 1;
  for (auto &i : (fac)) {
    long long t = 0;
    long long mul = i;
    while (true) {
      t += B / mul;
      if ((double)mul * i > 2e18)
        break;
      else if (mul * i > B)
        break;
      mul *= i;
    }
    res = res * mpow(i, t) % MOD;
  }
  cout << res << '\n';
}
