#include <stdio.h>

int main(){
int H1,H2,M1,M2;
int s;
 
  scanf("%d" , &H1);
  scanf("%d" , &M1);
  scanf("%d" , &H2);
  scanf("%d" , &M2);
  
  s = (H2 - H1)*60;
  s = s + M2 - M1;
  
  printf("%d",s);

return 0;
}