#include <stdio.h>

int main(void)
{
  int h1, m1, h2, m2, ken, han, man, fan;
  
  scanf("%d",&h1);
  scanf("%d",&m1);
  scanf("%d",&h2);
  scanf("%d",&m2);
  scanf("%d",&ken);

  while(m2-ken < 0){
    ken = ken-(m2+1);
  	m2 = 59;
    h2--;
  }
  m2 -= ken;
  
  han = (h2 - h1) * 60;
  man = m2 - m1;
  fan = han + man;
    
  printf("%d",fan);
  return 0;
}