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