#include<stdio.h>
 
int main(){
  int H1,H2,M1,M2,K;

  
  
  while(scanf("%d %d %d %d %d",&H1,&M1,&H2,&M2,&K)==0);
  
    int hm1=H1*60+M1;
  int hm2=H2*60+M2;
  int T=hm2-hm1;
  
  int A=T-K;
  
  printf("%d",A);
 
 return 0;
  
}