"use strict";

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