#include<stdio.h>
int main(void){
  	int a,b,c,d,e;
  	int h1 = 0;
  	int h2 = 0;
  	int ans = 0;
  scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
  h1 = a * 60 + b;
  h2 = c * 60 + d;
  ans = h1 - h2;
  printf("%d\n",ans - e);
  return 0;
}
  