#include <cstdint>
#include <cstdio>

namespace MMNMM{

    namespace Numeric{

        template<typename Integer = int_fast64_t>
        constexpr Integer extgcd(Integer a, Integer b, Integer &x, Integer &y){

            Integer u, v, q, tmp;
            x = v = 1;
            y = u = 0;

            while(b){

                q = a / b;
                x ^= u ^= x ^= u;
                u = u - q * x;
                y ^= v ^= y ^= v;
                v = v - q * y;
                a ^= b ^= a ^= b;
                b = b - q * a;

            }

            return a;

        }

        template<uint_fast64_t MOD = 1000000007>
        class modint{

        private:

            uint_fast64_t val;

        public:

            void id(){
                val = 1;
            }

            uint_fast64_t v()const{
                return val;
            }

            constexpr uint_fast64_t inverse()const{
                uint_fast64_t ret, tmp;
                extgcd(val, MOD, ret, tmp);
                return ret;
            }

            constexpr modint() : val(0){}

            constexpr modint(uint_fast64_t _val) : val(_val % MOD){}

            template <typename Integer>
            constexpr modint(Integer _val) : val(_val < 0 ? MOD - (-_val) % MOD : _val % MOD){}

            constexpr operator uint_fast64_t()const{return static_cast<uint_fast64_t>(val);}

            modint& operator=(const modint& rit){
                this->val = rit;
                return *this;
            }

            modint operator++(int){
                auto ret = this;
                ++(this->val);
                this->val -= this->val >= MOD;
                return ret;
            }

            modint operator--(int){
                auto ret = this;
                --(this->val);
                this->val += MOD * (this->val < 0);
                return ret;
            }

            modint& operator++(){
                ++(this->val);
                this->val -= MOD * (this->val >= MOD);
                return *this;
            }

            modint& operator--(){
                --(this->val);
                this->val += MOD * (this->val < 0);
                return *this;
            }

            modint operator-()const{
                return modint<>(MOD - this->val);
            }

            modint operator+()const{
                return this;
            }

            modint& operator*=(const modint& rit){
                this->val *= rit.v();
                this->val %= MOD;
                return *this;
            }

            modint& operator+=(const modint& rit){
                this->val += rit.v();
                this->val -= MOD * (this->val >= MOD);
                return *this;
            }

            modint& operator-=(const modint& rit){
                this->val -= rit.v();
                this->val += MOD * (this->val < 0);
                return *this;
            }

            modint& operator/=(const modint& rit){
                this->val *= rit.inverse();
                this->val %= MOD;
                return *this;
            }

        };

        modint<> operator"" _m(unsigned long long int t){
            return modint<>(t);
        }

        template <uint_fast64_t MOD = 1000000007>
        modint<MOD> operator*(const modint<MOD>& lft, const modint<MOD>& rit){
            return modint<MOD>(lft) *= rit;
        }

        template <uint_fast64_t MOD = 1000000007>
        modint<MOD> operator+(const modint<MOD>& lft, const modint<MOD>& rit){
            return modint<MOD>(lft) += rit;
        }

        template <uint_fast64_t MOD = 1000000007>
        modint<MOD> operator-(const modint<MOD>& lft, const modint<MOD>& rit){
            return modint<MOD>(lft) -= rit;
        }

        template <uint_fast64_t MOD = 1000000007>
        modint<MOD> operator/(const modint<MOD>& lft, const modint<MOD>& rit){
            return modint<MOD>(lft) /= rit;
        }

        template <uint_fast64_t MOD = 1000000007>
        bool operator==(const modint<MOD>& lft, const modint<MOD>& rit){
            return lft.v() == rit.v();
        }

        template <uint_fast64_t MOD = 1000000007>
        bool operator!=(const modint<MOD>& lft, const modint<MOD>& rit){
            return !(lft == rit);
        }

        void id(uint_fast64_t& t){
            t = 1;
        }

        template <uint_fast64_t MOD = 1000000007>
        void id(modint<MOD>& t){
            t = 1;
        }

        template <typename Monoid>
        Monoid modpow(Monoid a, size_t n){
            Monoid ret;
            id(ret);
            while(n){
                if(n & 1){
                    ret *= a;
                }
                a *= a;
                n /= 2;
            }
            return ret;
        }

    }

}

int main(){
    MMNMM::Numeric::modint<> a, b;
    scanf("%lld%lld", &a, &b);
    printf("%lld\n", MMNMM::Numeric::modpow(a, b));
    return 0;
}


Measured memory_bytes: 2756