#include<stdio.h>

int main() {
    int h1,m1,h2,m2,k;
    int time_1;
    int i;

    scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2,&k);
    time_1 = (h2 - h1) * 60 + (m2 - m1);
    printf("%d\n", time_1 - k);
    return 0;
}