

#include<bits/stdc++.h>
#include<sstream>
#include<string>
using namespace std;
#define rep(i,ii,n) for(int i=ii;i<n;i++)
#define inf INT_MAX
#define mod (1000000007LL)
#define ll long long 
#define ull unsigned long long 
#define all v.begin(),v.end()
#define vi vector<int>
#define pb push_back



int main(){ 
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    cout<<(60*h2+m2)-(k)-(60*h1+m1)<<endl;

 




 return 0;   
}//main

