#include<bits/stdc++.h>
using namespace std;
const double PI=3.141592;
vector<double> f(double a,double b){
    a=a/180.0*PI;
    b=b/180.0*PI;
    vector<double>ret(3);
    ret[0]=cos(a)*sin(b);
    ret[1]=sin(a);
    ret[2]=cos(a)*cos(b);

    return ret;
}

int main(){
    while(true){
        double a1,b1,a2,b2;
        scanf("%lf%lf%lf%lf",&a1,&b1,&a2,&b2);
        if(a1==-1&&b1==-1&&a2==-1&&b2==-1)break;

        vector<double>v1,v2;

        v1=f(a1,b1);
        v2=f(a2,b2);

        double dot=0;
        for(int i=0;i<3;i++)dot+=v1[i]*v2[i];
        double rad=acos(dot);
        rad*=6378.1;
        printf("%d\n",(int)(rad+0.5));
    }
}