#include <stdio.h>

int main(){
	int H1, M1, H2, M2, K;
	scanf("%d %d %d %d %d", &H1, &M1, &H2, &M2, &K);
	
	int A = H1 * 60 + M1;
	int B = H2 * 60 + M2 - K;
	
	printf("%d", (A-B)*-1);
	
	
	return 0;
}