#include<stdio.h>

int main(void){

	int getUpHour, getUpMin, sleepHour, sleepMin, studyTime;	
	int wakeTime = 0, startTime = 0;
	
	scanf("%d%d%d%d%d", &getUpHour, &getUpMin, &sleepHour, &sleepMin, &studyTime);

	wakeTime = (sleepHour - getUpHour) * 60;
	if (sleepMin > getUpMin)
	{
		wakeTime += sleepMin - getUpMin;
	}
	else
	{
		wakeTime -= getUpMin - sleepMin;
	}

	startTime = wakeTime - studyTime;

	printf("%d", startTime);

	}