#include <stdio.h>

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