#include <stdio.h>

int main (void)
{
  int h1,m1,h2,m2,k;
  int s1,s2;
  int total;
  
  scanf("%d %d %d %d %d", &h1,&m1,&h2,&m2,&k);
  
  if(h2>h1)
   s1 = h2 - h1;
  else
    s1 = h1 -h2;
  
  if(m1<m2)
    s2 = m2 - m1;
  else
    s2 = m1 - m2;
  
  total = s1*60 + s2 - k;
  
  printf("%d", total);
  
  return 0;
}
