#include <iostream>

int solve(){
    int h1, m1, h2, m2, k;
    scanf("%d", &h1);
    scanf("%d", &m1);
    scanf("%d", &h2);
    scanf("%d", &m2);
    scanf("%d", &k);

    int res;
    res = (h2-h1)*60+(m2-m1)-k;
    return res;
}

int main(){
    int res = solve();
    printf("%d\n", res);
    return 0;
}