#include<bits/stdc++.h>

int main(){
        int h, m, k;
        scanf("%d %d", &h, &m);
        int s = h*60 + m;
        scanf("%d %d", &h, &m);
        int g = h*60 + m;
        scanf("%d", &k);
        printf("%d\n", std::max(0, g-s-k));
        return 0;
}

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

int main(){
    int h1, h2, m1, m2 , k; cin >> h1 >> m1 >> h2 >> m2 >> k;
    m1 += 60 *  h1; m2 += h2 * 60;
    cout << m2 - m1 - k << '\n';
    return 0;
}