"""
TITLE: Integer Come in All Sizes

INPUT:
9
29
7
27

OUTPUT:
4710194409608608369201743232

"""

a = int(input())
b = int(input())
c = int(input())
d = int(input())
print(sum((pow(a, b), pow(c, d))))