#include<stdio.h>
#include<math.h>

int main(void) {

  int h1, m1, h2, m2, k, t;
  scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);

  t = ((h2*60+m2)-k) - (h1*60+m1);

  printf("%d\n", t);

  return 0;
}
