#include <stdio.h>
#define loop(a,b) for(int i=a;i<b;i++)
#define loop2(a,b) for(int j-a;j<b;j++)
int main(){
	
	int ha,ma,hb,mb,k;
	scanf("%d %d %d %d %d", &ha, &ma, &hb, &mb ,&k);
	int time1 = ha*60 + ma;
	int time2 = hb*60 + mb;
	int length = time2 - k - time1;
	printf("%d\n", length);
	
	return 0;
}