#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;
	if(((time1-time2)*-1)<k){
		if(time1-study<k){
		  printf("%d\n", study-time1);
	}
	}
	else{
		printf("0\n");
	}
	
	
	return 0;
}

