#include<stdio.h>

int max(int a, int b){
  if(a > b) return a;
  else return b;
}

int main(){

  int h1,m1,h2,m2,k;
  scanf("%d %d %d %d %d",&h1,&m1,&h2,&m2,&k);

  int ans = (h2*60 + m2) - (h1*60 + m1) - k;
  ans = max(ans,0);

  printf("%d",ans);

  return 0;
}
