import std.stdio, std.string, std.array, std.conv;

long modexp(long x, long n) {
    if (n == 0) return 1;
    long mod = 1_000_000_007;
    long result = modexp(x, n/2);
    result = result * result % mod;
    if (n % 2 == 1) result = result * x % mod;
    return result;
}

void main() {
    long[] tmp = readln.chomp.split.to!(long[]);
    long m = tmp[0], n = tmp[1];
    modexp(m, n).writeln;
}
