#include<stdio.h>
 
int main(){
  int H1,H2,M1,M2,K;
  int H=H2-H1;
  int M=M2-M1;
  int hm1=H1*60+M1;
  int hm2=H2*60+M2;
  int T=H*60+M;
  
  
  while(scanf("%d %d %d %d %d\n",&H1,&M1,&H2,&M2,&K)==0);
  int A=T-K;
  
  printf("%d",A);
 
 return 0;
  
}