m, n = gets.split(" ").map(&:to_i)
mod = 1000000007

def power(m, n, mod)
  if n == 0
    return 1
  elsif n % 2 == 0
    return power((m*m)%mod, n/2, mod)
  else
    return (m * power(m, n-1, mod))%mod
  end
end

puts power(m,n,mod)%mod

