#include<iostream>
using namespace std;
int main()
{
int a;
int b;
int c;
int d;
while(cin>>a>>b>>c>>d && 0<=a<=23 && 0<=c<=23 && 0<=b<=59 && 0<=d<=59)
{
if( a==0 && b==0 && c==0 && d==0)
break;
if(a>c)
{int y=((c-a)+24)*60;
cout<<y+(d-b)<<endl;}
if(a==b==c==d && a!=0)
cout<<0<<endl;
if(a<c)
{int x=(c-a)*60;
cout<<x+(d-b)<<endl;}
if(a==c && b<d)
{cout<<d-b<<endl;}
if(a==c && b>d)
{cout<<1440+(d-b)<<endl;}
}
return 0;
}