__author__ = 'jacobreed'
#Simply adds and tests the functionality of large integer outputs. For large test cases.
a = int(raw_input())
b = int(raw_input())
c = int(raw_input())
d = int(raw_input())

print pow(a,b)+pow(c,d)