import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long powMod(long x, long k, long m) {
    if (k == 0) return 1;
    if (k % 2 == 0) return powMod(x * x % m, k / 2, m);
    return x * powMod(x, k - 1, m) % m;
}

void main() {
    auto mn = readints;
    int m = mn[0], n = mn[1];
    const int mod = 10^^9 + 7;

    auto ans = powMod(m, n, mod);
    writeln(ans);
}
