#include <stdio.h>
int main(void){

	int a, b, c, d, e,f,g,h,i;

	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	scanf("%d", &d);
	scanf("%d", &e);



	if (d >= a) {

		f = d - a;
		g = c - a;
		h = g * 60 + f;
		i = h - e;
		printf("%d", i );

	}

	else if (d < a) {

		f = d + 60 - a;
		g = c - a - 1;
		h = g * 60 + f;
		i = h - e;



		printf("%d", i);
	}
		




	return 0;
}