import std.stdio;
import std.math;
import std.conv;
import std.string;

void main()
{
    ulong n,m;
    string[] s = readln.chomp.split();
    m = s[0].to!ulong, n = s[1].to!ulong;
    
    ulong a = pow(m, n)%1000000007;
    
    writeln(a);   
}