import Control.Applicative

d = 1000000007

pow :: Integer -> Integer -> Integer
pow m n = pow' m n 1

pow' :: Integer -> Integer -> Integer -> Integer
pow' m n oddtime
    | n == 0 = oddtime
    | even n = pow' (m*m `mod` d) (n `div` 2) oddtime
    | odd n = pow' (m*m `mod` d) (n `div` 2) (oddtime*m)

main = do
    [m, n] <- words <$> getLine
    putStrLn $ show $ (pow (read m::Integer) (read n::Integer)) `mod` d