#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)
      continue;
    else if(H2>23)
      continue;
    else if(M1>59)
      continue;
    else if(M2>59)
      continue;
    else if(H1>H2)
      continue;
    else if(M1>M2)
      continue;
    else if(T<0)
      continue;
    
}
     
        printf("%d",T);
        
  return 0;
}