You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket.  Find the minimum total fare when the optimal choices are made for trains and buses.
a = int(input())
b = int(input())
c = int(input())
d = int(input())
train = a
if a > b:
    train = c
bus = c
if c > d:
    bus = d
print(train + bus)
a = int(input())
b = int(input())
c = int(input())
d = int(input())
train = a
if a > b:
    train = b
bus = c
if c > d:
    bus = d
print(train + bus)