function Main(input) {
  var inputs = input.split(" ");
  var h1 = parseInt(inputs[0], 10);
  var m1 = parseInt(inputs[1], 10);
  var h2 = parseInt(inputs[2], 10);
  var m2 = parseInt(inputs[3], 10);
  var k = parseInt(inputs[4], 10);
  
  var minute1 = h1 * 60 + m1;
  var minute2 = h2 * 60 + m2;
  
  var difference = minute2 - minute1;
  console.log(difference - k);
}  
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
