function Main(input) {
  input = input.replace(/\n/g, ' ');
  input = input.split(" ");
  var A = Number(input[0]);
  var B = Number(input[1]);
  var C = Number(input[2]);
  var D = Number(input[3]);
  var E = Number(input[4]);
  if(A>C){C+=24;}
  var a = A*60+B;
  var b = C*60+D;
  console.log(b-a-E);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));