#include <stdio.h>

int main(){
    
    int H1, M1, H2, M2, K;

    scanf("%d %d %d %d %d", &H1, &M1, &H2, &M2, &K);
    int output = ((H2 - H1)*60) + M1 + M2;
    if(output == K){
    	printf("0\n");
	}
	    printf("%d\n", output);
    return 0;
}