#include<iostream>
#define M 1000000007
using namespace std;
typedef unsigned long long ullong;

ullong power(ullong m, ullong n){
  ullong res = 1;
  if ( n > 0){
    res = power(m * m % M , n / 2);
    if ( n % 2 == 1) res = res * m % M;
  }
  return res;
}

int main(){
  ullong m, n;
  cin >> m >> n;

  cout << power(m, n) << endl;

  return 0;
}
