#include <stdio.h>
int main(void){
    int h1,m1,h2,m2,k,h1_m,h2_m,d;
    
    scanf("%d %d %d %d %d", &h1,&m1,&h2,&m2,&k);
    
    h1_m=h1*60;
    h2_m=h2*60;
    d=h2_m+m2-(h1_m+m2)-k;
    
    printf("%d\n",d);
    
    return 0;
}
