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 m, n;
    readVars(m, n);

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

    writeln(ans);
}

T modpow(T)(T x, T y, T 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");
    }
}