#include<stdio.h>
main(){
	int H1 = 0;
    int M1 = 0;
  	int H2 = 0;
  	int M2 = 0;
  	int K = 0;
 	int i = 0;
  	int j = 0;
  	int k = 0;
  	
  	scanf("%d %d %d %d %d", &H1, &M1, &H2, &M2, &K);
  	i = H1 * 60 + M1;
  	j = H2 * 60 + M2;
  	k = j - K - i;
  
  	printf("%d", k);
}