#include <bits/stdc++.h>
using namespace std;
vector<long long int> singlefactorise(long long int a) {
  set<long long int> salman;
  for (int i = 2; i * i <= a; i++) {
    while (a % i == 0) {
      salman.insert(i);
      a /= i;
    }
  }
  if (a != 1) salman.insert(a);
  vector<long long int> kaif;
  for (set<long long int>::iterator it = salman.begin(); it != salman.end();
       it++)
    kaif.push_back(*it);
  return kaif;
}
long long int modularexpo(long long int x, long long int n) {
  long long int result = 1;
  while (n) {
    if (n % 2 == 1) result = (result * x) % 1000000007;
    x = (x * x) % 1000000007;
    n = n / 2;
  }
  return result;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int x, n;
  cin >> x >> n;
  vector<long long int> v = singlefactorise(x);
  long long int ans = 1;
  for (int i = 0; i < v.size(); i++) {
    long long int b = v[i];
    long long int curr = 0;
    long long int y = n;
    while (y) {
      y = y / b;
      curr = curr + y;
    }
    ans =
        ((ans % 1000000007) * (modularexpo(b, curr) % 1000000007)) % 1000000007;
  }
  cout << ans << endl;
  return 0;
}
