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.
def solver(a, b, c, d):
  """
  >>> solver(600, 300, 220, 420)
  520
  >>> solver(555, 555, 400, 200)
  755
  >>> solver(549, 817, 715, 603)
  1152
  """

  result = 0

  result += a if a < b else b
  result += c if c < d else d

  return result

if __name__ == '__main__':
  inputs = [int(input()) for _ in range(4)]
  solver(inputs[0], inputs[1], inputs[2], inputs[3])

def solver(a, b, c, d):
  """
  >>> solver(600, 300, 220, 420)
  520
  >>> solver(555, 555, 400, 200)
  755
  >>> solver(549, 817, 715, 603)
  1152
  """

  result = 0

  result += a if a < b else b
  result += c if c < d else d

  return result

if __name__ == '__main__':
  inputs = [int(input()) for _ in range(4)]
  print(solver(inputs[0], inputs[1], inputs[2], inputs[3]))
