
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
  double a,b,c,d;
  double BC,CA,C;
  while(cin>>a>>b>>c>>d,a!=-1|b!=-1|c!=-1|d!=-1){
    BC=M_PI*(90.0-a)/180.0;
    CA=M_PI*(90.0-c)/180.0;
    C=M_PI*(d-b)/180.0;
    cout<<(int)(0.5+6378.1*acos(cos(BC)*cos(CA)+sin(BC)*sin(CA)*cos(C)))<<endl;
  }
}