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