#include <stdio.h>

int main(){
	int up_h, up_m, gt_h, gt_m, stu_m, all_m;

	scanf("%d %d %d %d %d", &up_h, &up_m, &gt_h, &gt_m, &stu_m);

	all_m = ((gt_h - up_h)*60)+(gt_m - up_m);

	printf("%d",all_m-stu_m);
	return 0;
}
