const readline = require("readline");
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

totalMins = 0;
let stratFrom = 0;

rl.on('line', function(data){
    data = data.split(' ');
    //console.log(data);

    let from = parseInt(data[0]) * 60 + parseInt(data[1]);
    let to = parseInt(data[2]) * 60 + parseInt(data[3]);
    totalMins = to - from;
    //console.log(totalMins);

    stratFrom = totalMins - parseInt(data[4]);
    //console.log(stratFrom);
    rl.close();
});

rl.on('close', function(){
    console.log(`${stratFrom}`);
})