#include <bits/stdc++.h>
using namespace std;
const long long int N = 3e5 + 5, inf = 1e9 + 7;
long long int bigmod(long long int b, long long int p, long long int m) {
  long long int rt = 1;
  while (p) {
    if (p & 1) rt = (rt * b) % m;
    b = (b * b) % m;
    p >>= 1;
  }
  return rt;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int tc = 1, t = 0;
  while (tc--) {
    long long int x, n;
    cin >> x >> n;
    vector<long long int> prim;
    for (int i = 2; i * i <= x; i++) {
      if (x % i == 0) {
        prim.push_back(i);
        while (x % i == 0) x /= i;
      }
    }
    if (x > 1) prim.push_back(x);
    long long int rs = 1;
    for (auto x : prim) {
      long long int fact = x, pw = 0;
      while (fact <= n) {
        pw += n / fact;
        if (n / x >= fact)
          fact *= x;
        else
          break;
      }
      rs *= bigmod(x, pw, inf);
      rs %= inf;
    }
    cout << rs << "\n";
  }
  return 0;
}
