#include <stdio.h>

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