import scala.io.{StdIn => in}

object Main extends App {
  val train = Iterator.continually(in.readInt).take(2).min
  val bus   = Iterator.continually(in.readInt).take(2).min
  val ans = train + bus
  println(ans)
}