#include <stdio.h>

int main()
{
int k;
int H1, H2;
int M1, M2;
        scanf("%d %d %d %d %d", &H1, &M1, &H2, &M2, &k);
int l =(H2 * 60 + M2) -(H1 * 60 + M1) - k;
        printf("%d\n", l);
  
  return 0;
}