#include <stdio.h>

int main(){
	
	int h1, m1, h2, m2, k;
	
	scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);
	
	int jam=h2-h1;
	int menit=m2-m1;
	
	int jumlahjam=jam*60;
	
	int hasil=jumlahjam+menit-k;
	
	printf("%d\n", hasil);
	
	return 0;
}