#include <iostream>
using namespace std;
int main()
{
int h1,m1,h2,m2,a,b,c;
0<=h1<=23;
0<=m1<=59;
0<=h2<=23;
0<=m2<=59;
while(cin>>h1>>m1>>h2>>m2)
{
if(h2-h1>0)
{
a=(h2-h1)*60+m2-m1;
cout<<a<<endl;
}
else if(h2-h1<0)
{
b=(h2+24)*60+m2-h1*60-m1;
cout<<b<<endl;
}
else if(h1!=0&&h2!=0&&h2-h1==0)
{
c=24*60-m1+m2;
cout<<c<<endl;
}
else if(h1+h2+m1+m2==0)
{
break;
}
}
return 0;
}
求解拜託~~