#include <bits/stdc++.h>
using namespace std;
long long power(int x, unsigned int y, long long p = 1000000007) {
  long long res = 1;
  x = x % p;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
int main() {
  int n, m;
  cin >> n >> m;
  cout << power(n, m, 1000000007);
  return 0;
}
