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