#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
#ifdef LOCAL
template <typename A, typename B> string to_string(pair<A, B> p);
template <typename A, typename B, typename C> string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D> string to_string(tuple<A, B, C, D> p);
string to_string(const string& s) {return '"' + s + '"';}
string to_string(const char* s) {return to_string((string) s);}
string to_string(bool b) {return (b ? "true" : "false");}
string to_string(vector<bool> v) {bool first = true;string res = "{";for (int i = 0; i < static_cast<int>(v.size()); i++) {if (!first) {res += ", ";}first = false;res += to_string(v[i]);}res += "}";return res;}
template <size_t N>string to_string(bitset<N> v) {string res = "";for (size_t i = 0; i < N; i++) {res += static_cast<char>('0' + v[i]);}return res;}
template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A, typename B, typename C>string to_string(tuple<A, B, C> p) {return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";}
template <typename A, typename B, typename C, typename D>string to_string(tuple<A, B, C, D> p) {return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";}
void debug_out() { cerr << "\n"; }
template <typename Head, typename... Tail>void debug_out(Head H, Tail... T) {cerr << " " << to_string(H);debug_out(T...);}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define trace(a, n) cerr << #a << "[" << n <<  "] = ["; for (int i = 0; i < n; i++) cerr << a[i] << ", "; cerr << "]\n"
#else
#define debug(...) 42
#define trace(a, n) 42
#endif
#define int long long int
#define double long double
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define len(x) (int)x.length()
#define forn(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i <= b; i++)
#define BWD(i, a, b) for (int i = a; i >= b; i--)
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define uint unsigned int
#define pi pair<int, int>
#define vi vector<int>
#define vii vector<pi>
#define vvi vector<vi>
#define mi map<int, int>
#define vb vector<bool>
#define vs vector<string>
const int infi = 1e9;
const long long infl = 1e18;
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;
template <typename Map>bool map_compare (Map const &lhs, Map const &rhs) { return lhs.size() == rhs.size() && std::equal(lhs.begin(), lhs.end(), rhs.begin());}
template <class T, class Cmp = less<T>> using oset = tree<T, null_type, Cmp, rb_tree_tag, tree_order_statistics_node_update>;
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937_64 rng(seed);
int modpow(int x, int n) { int res = 1; while (n > 0) { if (n % 2) res = (res * x) % MOD; x = (x * x) % MOD; n /= 2; } return res; }
int inv(int x) {return modpow(x, MOD-2);}
long long log_2 (long long n) { return (n > 1ll)? 1ll + log_2(n/2): 0ll;}
long long log_10 (long long n) { return (n > 1ll)? 1ll + log_10(n/10): 0ll;}
inline int add(int a, int b) {return ((a % MOD) + (b % MOD)) % MOD;}
inline int sub(int a, int b) {return ((a % MOD) - (b % MOD) + MOD) % MOD;}
inline int mul(int a, int b) {return ((a % MOD) * (b % MOD)) % MOD;}
int gcd(int a, int b) { int r; while (b) { r = a % b; a = b; b = r;} return a; }
int randint (int limit = MOD) { uniform_int_distribution<int> dis(0, limit); return dis(rng); }
double random (double limit = (double)MOD) { uniform_real_distribution<double> dis((double)0, limit); return dis(rng); }

template <class T>
struct cmp {
  bool operator() (const T& x, const T& y) const {
    return x > y;
  }
  typedef T first_argument_type;
  typedef T second_argument_type;
  typedef bool result_type;
};

signed main() {
#ifdef READ_FILE
  freopen("input.txt", "r", stdin);
#endif
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  if (h2 > h1 || (h1 == h2 && m2 > m1)) {
    int a = h1*60 + m1;
    int b = h2*60 + m2;
    int p = b - a;
    int ans = p - k;
    if (ans < 0) ans = 0;
    cout << ans << "\n";
  } else {
    h2 += 24;
    int a = h1*60 + m1;
    int b = h2*60 + m2;
    int p = b - a;
    int ans = p - k;
    if (ans < 0) ans = 0;
    cout << ans << "\n";
  }
  return 0;
}

Measured memory_bytes: 3656