import scala.io.StdIn

object Main extends App {
  val r = (0 until 2).map{ i =>
    var r1 = StdIn.readLine().toInt
    val r2 = StdIn.readLine().toInt
    if(r1 < r2) r1 else r2
  }.sum

  println(r)
}
