#include <stdio.h>

int main(){
  int h1, m1, h2, m2, k;
  scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);
  
  long start = h1*60 + m1;
  long end = h2*60 + m2;
  printf("%ld\n", end-start-k);
  return 0;
}
