#include<iostream>
using namespace std;
int main()
{
int A,B,C,D,x,y;
cin>>A>>B>>C>>D;
if(A<C&&B<=D){
x=C-A;
y=D-B;}
if(A<=C&&B>D){
x=C-A-1;
y=60-B+D;}
if(A>C&&B<=D){
x=24-A+C;
y=D-B;}
if(A>=C&&B>D){
x=C-A+23;
y=60-B+D;}
if(A==C&&B==D){
x=24;
y=0;
}
if(A==C&&B<D){
x=0;
y=D-B;
}
cout<<"O JOGO DUROU "<<x<<" HORA(S) E "<<y<<" MINUTO(S)"<<endl;
return 0;
}