#include <stdio.h>

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

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