#include <bits/stdc++.h>
using namespace std;
long long prime[100001];
bool c[100001];
const long long MOD = 1000000007;
long long mpow(long long a, long long b) {
  if (b == 0) return 1;
  if (b == 1) {
    return a % MOD;
  } else {
    if (b % 2 == 0) {
      return (mpow((a % MOD * a % MOD) % MOD, b / 2)) % MOD;
    } else {
      return (a % MOD * mpow(a % MOD, b - 1)) % MOD;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int idx = 0;
  for (long long i = 2; i < 100001; i++) {
    if (c[i] == false) {
      for (long long j = i * i; j < 100001; j += i) {
        c[j] = true;
      }
    }
  }
  long long x, n;
  cin >> x >> n;
  long long x2 = sqrt(x);
  for (int i = 2; i <= x2; i++) {
    if (x % i == 0 && c[i] == false) {
      prime[idx++] = i;
      while (x % i == 0) {
        x /= i;
      }
    }
  }
  if (x > x2) {
    prime[idx++] = x;
  }
  long long ans = 1;
  long long n2 = n;
  for (int i = 0; i < idx; i++) {
    long long t = prime[i];
    long long last = t;
    n2 = n;
    while (t <= n2) {
      long long dif = n2 / t;
      long long temp = mpow(prime[i], dif);
      ans *= temp;
      ans %= MOD;
      n2 /= prime[i];
    }
  }
  cout << ans;
}
