#include <bits/stdc++.h>
using namespace std;
int RidicareLogaritmica(int N, int P) {
  int r = 1;
  while (P) {
    if (P % 2 == 1) r = (1LL * r * N);
    N = (1LL * N * N);
    P = P / 2;
  }
  return r;
}
int main() {
  int a, b;
  scanf("%d%d", &a, &b);
  printf("%d", RidicareLogaritmica(a, b) % 1000000007);
  return 0;
}
