#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;

template<class T> ostream& operator << ( ostream& os, vector<T> v ) {
    for ( typename vector<T>::iterator it_i = v.begin(); it_i != v.end(); ++it_i ) {
        os << *it_i << ", ";
    }
    return os;
}


double toRad( double deg ) {
    return deg / 180.0 * M_PI;
}

double sq( double x ) {
    return x * x;
}

int solve( double a, double b, double c, double d ) {
    a = toRad(a), b = toRad(b), c = toRad(c), d = toRad(d);
    double R = 6378.1;
    double P[2][3];
    P[0][0] = R * cos(a) * cos(b);
    P[0][1] = R * cos(a) * sin(b);
    P[0][2] = R * sin(a);
    P[1][0] = R * cos(c) * cos(d);
    P[1][1] = R * cos(c) * sin(d);
    P[1][2] = R * sin(c);
    double D = sqrt( sq( P[0][0] - P[1][0] ) + sq( P[0][1] - P[1][1] ) + sq( P[0][2] - P[1][2] ) );
    double a0 = ( sq(R) + sq(R) - sq(D) ) / ( 2 * sq(R) );
    double a1 = acos(a0);
    return (int)( 1e-9 + 0.5 + M_PI * R * ( a1 / M_PI ) );
}

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