#include<stdio.h>
int MAX(int a){return a<0?0:a;}
int main(){
  int h,m,a,b;
  scanf("%d %d",&h,&m);
  a=h*60+m;
  scanf("%d %d",&h,&m);
  b=h*60+m;
  scanf("%d",&m);
  printf("%d\n",MAX(b-a-m));
  return 0;
}
