#include <stdio.h>

int main() {
	int h1, m1, h2, m2, k, start = 0, finish = 0, lo = 0;
	scanf("%d%d%d%d%d", &h1, &m1, &h2, &m2, &k);
	start = h1 * 60 + m1;
	finish = h2 * 60 + m2;
	lo = finish - start - k;
	printf("%d", lo);
	return 0;
}
