#include <stdio.h>
int main(void)
{
int h1, m1, h2, m2, k;
int start =0;
int end = 0;
scanf("%d%d%d%d%d", &h1, &m1, &h2, &m2, &k);
  
start = h1*60 + m1;
end = h2*60 + m2;
printf("%d", end -start - k);
return 0;
}