"use strict";
var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.trim().split(/ |\n/), cid = 0;

function main() {
    let h1 = +cin.shift();
    let m1 = +cin.shift();
    let h2 = +cin.shift();
    let m2 = +cin.shift();
    let k = +cin.shift();
    let d = (h2-h1)*60+(m2 - m1) -k;
    console.log(d);
}
main();
