#include<cstdio>
int main() {
  int a,b,c,d;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  b+=a*60;
  d+=c*60;
  printf("%d",d-b);
}