def power(m, n, mod = 1_000_000_007)
  n = n.to_s(2).split(//).map(&:to_i)
  result = 1
  n.each{|i|
    result *= result
    if i == 1
      result *= m
    end
    result %= mod
  }
  return result, test
end
puts power(gets.split(//).map(&:to_i))