#include<stdio.h>

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