import std.stdio;
import std.algorithm;
import std.math;
import std.conv;
import std.string;

T readNum(T)(){
  return readStr.to!T;
}

T[] readNums(T)(){
  return readStr.split.to!(T[]);
}

string readStr(){
  return readln.chomp;
}

void main(){
  auto k = readNums!int;

  auto start = k[0] * 60 + k[1];
  auto end = k[2] * 60 + k[3];
  writeln(end - start - k[4]);
}
