#include <stdio.h>
 
int main() {
	
	int H1, M1, H2, M2, K;

	int x, y;
	
	int z;
	
	if (scanf("%d %d %d %d %d", &H1, &M1, &H2, &M2, &K) != 5) {
		return 1;	
	}
	
	x = H1 * 60 + M1;
	
	y = H2 * 60 + M2;
 
	z = y - x - K;
	
	printf("%d\n", z >= 0 ? z : 0);
	
	return 0;
}