#include <stdio.h>

int main()
{
	int H1,M1,H2,M2,K;

	scanf("%d %d %d %d %d",&H1,&M1,&H2,&M2,&K);

	int H3 = H2 - H1;
	int M3 = M2 - M1;

	int sum = H3 * 60 + M3;
	printf("%d\n",sum - K);
	return 0;
}

