#include<iostream> using namespace std; int main() { double a,b,c,d; cin>>a>>b>>c>>d; cout<<(c-a)*60-b+d<<endl; return 0; }