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