#include<bits/stdc++.h>
using namespace std;

//----------------------------------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vp;
typedef map<ll,ll> mll;
typedef priority_queue<ll> maxHeap;
typedef priority_queue<ll,vll,greater<ll>> minHeap;

#define F first
#define S second
#define B begin()
#define E end()
#define L length()
#define SZ size()

#define f(i,a,b) for(int i=a;i<b;i++)
#define inp(a,n) f(i,0,n)cin>>a[i]
#define inpv(v,n,x) f(i,0,n){cin>>x;v.push_back(x);}
#define inpll(v,n,x) f(i,0,n){cin>>x;v.push_back({x,i});}
#define inpmat(a,n,m) f(i,0,n){f(j,0,m)cin>>a[i][j];} 
#define fr(i,s) for(auto i=s.B;i!=s.E;i++)

#define yesno(ans) cout<<(ans?"yes":"no")<<endl;
#define YESNO(ans) cout<<(ans?"YES":"NO")<<endl;
#define YesNo(ans) cout<<(ans?"Yes":"No")<<endl;
#define print(X) cout<<X<<endl;

#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define MOD 1000000007
#define itr iterator

//-----------------------------------------------------------------
template<class T> T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template<class T> T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
template<class T> T add(T a,T b) {return ((a)+(b))%MOD ; }
template<class T>T mul(T a,T b) {return ((a%MOD)*(b%MOD))%MOD ; }
ll fast_exp(ll base, ll exp) {
    ll res=1;
    while(exp>0){
        if(exp%2==1) res=(res*base)%MOD;
        base=(base*base)%MOD;
        exp/=2;
    }
    return res%MOD;
}
void printa(ll a[],ll n) {f(i,0,n)cout<<a[i]<<" ";cout<<endl;}
void printv(vll v) {fr(i,v)cout<<(*i)<<" ";cout<<endl;}
void printmat(ll *arr, ll m, ll n) {f(i,0,m){f(j,0,n) cout<< (*((arr+i*n) + j)) << " ";cout<<endl;}} 

int removeColon(string s) 
{ 
    if (s.size() == 4)  
        s.replace(1, 1, ""); 
      
    if (s.size() == 5)  
        s.replace(2, 1, ""); 
      
    return stoi(s); 
} 
  
// Main function which finds difference 
string diff(string s1, string s2) 
{ 
  
    // change string (eg. 2:21 --> 221, 00:23 --> 23) 
    int time1 = removeColon(s1); 
    int time2 = removeColon(s2); 
  
    // difference between hours 
    int hourDiff = time2 / 100 - time1 / 100 - 1; 
  
    // difference between minutes 
    int minDiff = time2 % 100 + (60 - time1 % 100); 
  
    if (minDiff >= 60) { 
        hourDiff++; 
        minDiff = minDiff - 60; 
    } 
  
    // convert answer again in string with ':' 
    string res = to_string(hourDiff) + ':' + to_string(minDiff); 
    return res; 
} 
//---------------------------MAIN-----------------------------------
int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    ll t=1,k,l,n,m,x,y,z,j,minn=MAX,maxx=MIN,a,b,c,d;
    bool flag;
    //cin >> t;
    // string newline;getline(cin,newline);
    while(t--) {
    	string sh,sm,eh,em;
    	int st;
    	cin >> sh >> sm >> eh >> em >> st;
    	
    	string start = sh;
    	start+=':';
    	if(sm.L==2) {start+=sm;}
    	else {start+='0';start+=sm;}
    	
    	string end=eh;
    	end+=':';
    	if(em.L==2) {end+=em;}
    	else {end+='0';end+=em;}
    	
    	string di = diff(start,end);
    	
    	
    	//cout << di << endl;
    	
    	
    	string hh="";
    	ll k=0;
    	while(di[k]!=':') {
    		hh+=di[k];
    		k++;
    	}
    	
    	
    	//cout << hh << endl;
    	
    	
    	
    	int hours = 0;
    	ll mul = 1;
    	for(int i=hh.L-1;i>=0;i--) {
    		hours += mul*(hh[i]-'0');
    		mul*=10;
    	}
    	
    	k++;
    	string mm = "";
    	while(k<di.L) {
    		mm+=di[k];
    		k++;
    	}
    	
    	//cout << mm << endl;
    	
    	int mins = 0;
    	mul = 1;
    	for(int i=mm.L-1;i>=0;i--) {
    		mins += mul*(mm[i]-'0');
    		mul*=10;
    	}
    	//cout << hours <<" " << mins << endl;
    	ll total = hours*60+mins-st;
    	cout << total << endl;
    }
    return 0;
}


Measured memory_bytes: 3744