#include<bits/stdc++.h>
using namespace std;
int main(){
    int a1,a2,b1,b2;
    cin>>a1>>a2;
    cin>>b1>>b2;
    int h = (b1-a1)*60;
    cout<< h+b2-a2 ;
}