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

const D rd = M_PI/180.0;
const D r = 6378.1;

int solve(D y1, D x1, D y2, D x2){
    D x = abs(x1-x2); if(x > 180.0) x = 360.0 - x;
    D d = r * acos(sin(y1*rd)*sin(y2*rd) + cos(y1*rd)*cos(y2*rd) * cos(x*rd));
    return (int)(d + 0.5);
}

int main(){
    D a,b,c,d;
    while(cin >> a >> b >> c >> d){
        if(a < 0 && b < 0 && c < 0 && d < 0) break;
        cout << solve(a,b,c,d) << endl;
    }
    return 0;
}