# -*- coding: utf-8 -*- n, = map(int, raw_input().split()) m, = map(int, raw_input().split()) print pow(n,m,129402307)