#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv) {
int a,b,c,d;
while(cin>>a>>b>>c>>d)
{
if(a==0&&b==0&&c==0&&d==0) break;
if(a<c||a==c&&b<d) cout<<(c-a)*60+d-b<<endl;
else if(a>c||a==c&&b>d) cout<<((c+24)*60+d)-(a*60+b)<<endl;
}
return 0;
}