#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int hour;
  int min;

  int t1, t2, t3;
  t3 = h2 * 60 + m2;
  t2 = t3 - k;
  t1 = h1 * 60 + m1;

  int ans;
  
  ans = t2 - t1;

  cout << ans << endl;


}
#include<cstdio>
#include<iostream>
using namespace std;

#define ll long long
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

char sep[2] = {' ', '\n'};

int main() {
  int i, j, k;
  int n;
  int a[110];

  cin >> n;
  rep(i, n) cin >> a[n - i - 1];
  rep(i, n) cout << a[i] << sep[(i == n - 1)];
  cout << flush;
  
  return 0;
}
  