#include <iostream>
#include <cmath>

using namespace std;

typedef long double ld;

const ld r = 6378.1;

ld dist(ld n1, ld n2, ld we) {
    ld h1 = r * sin(n1);
    ld h2 = r * sin(n2);
    ld p1 = r * cos(n1);
    ld p2 = r * cos(n2);
    ld sp = p1*p1 + p2*p2 - 2*p1*p2*cos(we);
    ld dh = h2 - h1;
    ld sl = dh*dh + sp;
    ld theta = acos(1-sl/(2*r*r));
    return r*theta;
}

ld rad(ld deg) {
    return deg / 180 * M_PI;
}

int main() {
    ld an, ae, bn, be;
    while (cin >> an >> ae >> bn >> be) {
        if (an == ae && ae == bn && bn == be && be == -1) break;
        cout << round(dist(rad(an), rad(bn), rad(ae-be))) << endl;
    }
    return 0;
}