import sys



mod = 10**9 + 7



def solve():

    m, n = list(map(int, input().split()))



    ans = modpow(m, n, mod)



    print(ans)



def modpow(x, y, mod):

    res = 1



    while y:

        if y & 1:

            res = (res * x) % mod



        x = (x * x) % mod

        y >>= 1



    return res



if __name__ == '__main__':

    solve()
import sys



mod = 10**9 + 7



def solve():

    m, n = list(map(int, input().split()))

    print((pow(m, n, mod)))



if __name__ == '__main__':

    solve()
import sys

mod = 10**9 + 7


def solve():
    m, n = list(map(int, input().split()))
    ans = modpow(m, n, mod)
    print(ans)


def modpow(x, y, mod):
    res = 1
    while y:
        if y & 1:
            res = (res * x) % mod
        x = (x * x) % mod
        y >>= 1
    return res


if __name__ == "__main__":
    solve()

import sys

mod = 10**9 + 7


def solve():
    m, n = list(map(int, input().split()))
    print((pow(m, n, mod)))


if __name__ == "__main__":
    solve()

-    ans = modpow(m, n, mod) -    print(ans) - - -def modpow(x, y, mod): -    res = 1 -    while y: -        if y & 1: -            res = (res * x) % mod -        x = (x * x) % mod -        y >>= 1 -    return res +    print((pow(m, n, mod)))