include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c,d;
cin>>a>>c;
cin>>b>>d;
cout<<(b-a)*60+d-c<< endl;
return 0;
}