#include <stdio.h>
#include <math.h>
 
int main(void) {

	int h1, m1, h2, m2, k;
	
	scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);
	
	h1 = h1 * 60;
	h2 = h2 * 60;
	
	
	printf("%d", (h2 + m2) - (h1 + m1) - k);
	
	
	
	
	return 0;
}