"use strict";

function main(arg) {
    arg         = arg.split("\n");
    const train = arg.slice(0, 2).map(n=>parseInt(n));
    const bus   = arg.slice(-2).map(n=>parseInt(n));
    
    const trainFare = train.reduce((m,n)=>m>n?n:m);
    const busFare   = bus.reduce((m,n)=>m>n?n:m);
    
    console.log(parseInt(trainFare) + parseInt(busFare));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));