#include <stdio.h>

int main(void)
{
	int H1,H2,M1,M2,K,answer;
	scanf("%d",&H1);
	scanf("%d",&M1);
	scanf("%d",&H2);
	scanf("%d",&M2);
	scanf("%d",&K);
	answer=(H2-H1)*60+(M2-M1)-K;
	printf("%d",answer);
	return 0;
}