#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
double a,b,c,d,R=6378.1,pi=acos(-1);
while(cin>>a>>b>>c>>d){
if(a==-1&&b==-1&&c==-1&&d==-1)break;
a*=pi/180;
b*=pi/180;
c*=pi/180;
d*=pi/180;
printf("%.0f\n",asin(sqrt(
(cos(a)*cos(b)-cos(c)*cos(d))*(cos(a)*cos(b)-cos(c)*cos(d))
+(cos(a)*sin(b)-cos(c)*sin(d))*(cos(a)*sin(b)-cos(c)*sin(d))
+(sin(a)-sin(c))*(sin(a)-sin(c)))*0.5)*2*R);
}
return 0;
}