#include <bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
const int maxn = 1e5 + 5;
const long long MOD = 1e9 + 7;
long long x, n;
int m;
long long a[maxn];
long long ans = 1;
void work(long long x) {
  long long k = x;
  for (int i = 2; i * i <= x; i++) {
    if (k % i == 0) {
      m++;
      a[m] = i;
    }
    while (k % i == 0) k /= i;
  }
  if (k > 1) {
    m++;
    a[m] = k;
  }
}
long long fastpow(long long x, long long k) {
  if (x == 0) return 1;
  if (x & 1) return (fastpow(x - 1, k) * k) % MOD;
  long long ans = fastpow(x >> 1, k);
  return (ans * ans) % MOD;
}
int main() {
  cin >> x >> n;
  work(x);
  for (int i = 1; i <= m; i++) {
    long long t = 0;
    for (long long k = n; k > 0; k /= a[i]) t += k / a[i];
    ans = (ans * fastpow(t, a[i])) % MOD;
  }
  cout << ans;
}
