# Integers Come In All Sizes "https://www.hackerrank.com/challenges/python-integers-come-in-all-sizes/problem"

# Enter your code here. Read input from STDIN. Print output to STDOUT

a, b, c, d = (int(input()) for _ in range(4))
print(pow(a, b) + pow(c, d))
