#include <iostream>
#include <cstring>
using namespace std;

int main() {
  int H1, M1, H2, M2, K, X1, X2;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  X1 = H1 * 60 + M1;
  X2 = H2 * 60 + M2;
  cout << X2 - X1 - K << endl;
  
  return 0;
}