#include <stdio.h>

int main()
{
	int mt,ht,h1,m1,h2,m2,s,ans;
	scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &s);
	ht=h2-h1;
	mt=m2-m1;
	ht=(ht*60)+mt;
	ans=ht-s;
	if (ans<=0)
	{
		printf("0");
		return 0;
	}
	else
	{
		printf("%d", ans);
	}
	
	
	
	return 0;
}