#include <stdio.h>

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