#include<iostream> using namespace std; int main(){ int x1,y1,x2,y2,t; cin>>x1>>y1>>x2>>y2; t=(x2-x1+24)%24*60-y1+y2; cout<<t<<endl; return 0; }