#include<stdio.h>
int main(){
	int h1,m1,h2,m2,k;
	scanf("%d %d %d %d %d",&h1,&m2,&h2,&m2,&k);
	int awal=h1*60;
	int akhir=h2*60;
	int total1=awal+m1;
	int total2=akhir+m2;
		printf("%d",(total2-(total1-k)));
	return 0;
}