#include<stdio.h>
#include<string.h>

int main(){
	int h1, m1, h2, m2, k;
	scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);
	int time1= (h1*60)+m1;
	int time2= (h2*60)+m2;
	int study= (14*60)+30;
	int tot=time1-time2;
	tot*=-1;
	int tot1=time1-study;
	tot1*=-1;
	if(tot>k){
	printf("%d\n", tot1);
	}
	else{
		printf("0\n");
	}
	
//	else if(tot>study){
//		printf("%d\n", )
//	}
	
	
	return 0;
}

