import std.stdio, std.string, std.conv, std.range, std.array, std.algorithm;
import std.uni, std.math, std.container, std.typecons, std.typetuple;
import core.bitop, std.datetime;

immutable long mod = 10^^9 + 7;
immutable long inf = mod;

void main(){
    long n, m;
    readVars(n, m);

    auto ans = modpow(n, m, mod);

    writeln(ans);
}

bool is_prime(int x){
    for(int i = 2; i*i <= x; ++i){
        if (x % i == 0) {
            return false;
        }
    }

    return true;
}

T modpow(T)(T x, T y, T mod){
    T res = 1;

    while(y > 0){
        (res *= x^^(y&1)) %= mod;
        y >>= 1;
        x = x^^2 % mod;
    }

    return res;
}

void readVars(T...)(auto ref T args){
    auto line = readln.split;
    foreach(ref arg ; args){
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    if(!line.empty){
        throw new Exception("args num < input num");
    }
}