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

immutable long MOD = 1_000_000_007;
alias tie = TypeTuple;
alias triplet = Tuple!(int, int, int);

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

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

    writeln(ans);
}

int gcd(int x, int y){
    return y ? gcd(y, x % y) : x;
}

long modpow(long x, long y, long mod){
    return y ? ((modpow(x, y>>1, mod)^^2) % mod * x^^(y&1)) % mod : 1;
}


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");
    }
}