#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

const double pi = 4 * atan(1);
const double r = 6378.1;
const double circ = 2 * r * pi;

double dist(double x1, double y1, double z1, double x2, double y2, double z2) {
    return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) + (z1-z2)*(z1-z2));
}

int main() {
    double a, b, c, d;
    while (cin >> a >> b >> c >> d, (a!=-1 || b!=-1 || c!=-1 || d!=-1)) {
        a = a * pi / 180.0;
        b = b * pi / 180.0;
        c = c * pi / 180.0;
        d = d * pi / 180.0;

        double x1 = r * cos(a) * cos(b);
        double y1 = r * cos(a) * sin(b);
        double z1 = r * sin(a);

        double x2 = r * cos(c) * cos(d);
        double y2 = r * cos(c) * sin(d);
        double z2 = r * sin(c);

        double d = dist(x1, y1, z1, x2, y2, z2);

        double angle = acos((2*r*r - d*d) / (2*r*r));
        double res = circ * angle / (2 * pi);

        cout << (int)(res + 0.5) << endl;
    }
    return 0;
}