"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const H1 = parseInt(arg[0].split(" ")[0]);
    const M1 = parseInt(arg[0].split(" ")[1]);
    const H2 = parseInt(arg[0].split(" ")[2]);
    const M2 = parseInt(arg[0].split(" ")[3]);
    const K  = parseInt(arg[0].split(" ")[4]);
    
    const first = 60 - M1;
    const time1 = H2 - (H1 + 1);
    const rest = M2;
    
    let answer = first + (60 * time1) + M2 - K;
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));