"""
Task
Read four numbers, a, b, c, and d, and print the result of a^b + c^d.

"""

# Enter your code here. Read input from STDIN. Print output to STDOUT
a = int(input())
b = int(input())
c = int(input())
d = int(input())
print(a**b + c**d)
