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