#include<stdio.h>
 
int main(){
  
  int H1,M1,H2,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((H1>23)||(H2>23)||(M1>59)||(M2>59)||(H1>H2)||(M1>M2)||(h==m==0)||(T<0))
      continue;
}
     
        printf("%d\n",T);
        
  return 0;
}