#include <cstdio>
#include <iostream>
#include <cmath>
using namespace std;
typedef double D;

const D rd = acos(-1.0)/180.0;
const D r = 6378.1;

struct P3D {
    D x,y,z;
    P3D(D lat, D lon){
        x = cos(lat*rd)*cos(lon*rd);
        y = cos(lat*rd)*sin(lon*rd);
        z = sin(lat*rd);
    }
    D dist(const P3D &p){
        return (x-p.x)*(x-p.x) + (y-p.y)*(y-p.y) + (z-p.z)*(z-p.z);
    }
};

int main(){
    D a,b,c,d;
    while(cin>>a>>b>>c>>d){
        if(a<0 && b<0 && c<0 && d<0) break;
        P3D p1(a, b), p2(c, d);

        // 直線距離
        D c2 = p1.dist(p2);
        // 余弦定理(a^2 + b^2 -2ab cos(C) = c^2 )
        cout << (int)(r * acos(1-c2/2) + 0.5) << endl;
    }
    return 0;
}