#include <stdio.h>
int main(void){
    // Your code here!
    int h1, m1, h2, m2, k;
    scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);
    int timea, hour;
    hour = h2 - h1;
    timea = hour*60 + m2 - m1 - k;
    printf("%d", timea);
}
