//
//  nomura_a.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
#include <queue>
#include <map>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
ll mod = 998244353;
ll INF = 1000000007;
#define PI 3.14159265

pair<int, int> dijsktra(int x, char des, int n, vector<pair<int, char> > *adj) {
  priority_queue<pair<pair<int, char>, int> >  q; // (-d, x) current distance to node x is d, using -d to find minimum distance
  bool processed[n];
  pair<int, char> distance[n];
  for (int i=0; i<n; i++) {
    distance[i].first = INF;
    distance[i].second = '0';
    processed[i] = false;
  }
  // find from x
  distance[x] = make_pair(0, '0');
  q.push({distance[x], x});

  while (!q.empty()) {
    int a = q.top().second;
    q.pop();
    if (processed[a]) continue;;
    processed[a] = true;
    for (auto u: adj[a]) {
      int b = u.first; // node b
      char label = u.second;
      int w = 1; // distance from a to b is w
      if (distance[b].first > distance[a].first + w) {
        distance[b] = make_pair(distance[a].first + w, label);
        q.push({{-distance[b].first, label}, b});
      }
    }
  }

  int l = INF;
  int end = 0;
  // std::cout << "distance from " << x << std::endl;
  for (int i = 0; i < n; i++) {
    if (distance[i].first==INF) continue;
    if (distance[i].second == des && distance[i].first < l) {
      l = distance[i].first;
      end = i;
    }
    // std::cout << " distance to " << i << ": " << distance[i] << std::endl;
  }

  return make_pair(l, end);
}


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

  std::cout << h2*60+m2 - (h1*60+m1) - k << std::endl;

  return 0;
}
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <stdio.h>
#include <unistd.h>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)
#define itrep(itr, base) for (auto itr = base.begin(); itr != base.end(); itr++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl
#define PI 3.14159265359

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const int mod = 1000000007;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int h[2], m[2], k;
  cin >>  h[0] >> m[0] >> h[1] >> m[1] >> k;
  int up   = h[0] * 60 + m[0];
  int down = h[1] * 60 + m[1];
  if (down - up - k < 0) {
    P(0);
  } else {
    P(down - up - k);
  }
  return 0;
}
