
def main():


    num1 = int(raw_input())
    num2 = int(raw_input())
    num3 = int(raw_input())
    num4 = int(raw_input())
    print(num1**num2 + num3**num4)


    return None

if __name__ == "__main__":
    main()
