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

int main(void)
{
  int h1,h2,m1,m2,k;

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

  int start = 60*h1+m1;
  int end = 60*h2+m2;

  printf("%d\n",end-start-k);

  return 0;
}