#include<bits/stdc++.h>
using namespace std;

int main(){
    double a, b, c, d;
    while(cin >> a >> b >> c >> d, a + 1 || b + 1 || c + 1 || d + 1)
    {
        a *= M_PI / 180;
        b *= M_PI / 180;
        c *= M_PI / 180;
        d *= M_PI / 180;
        printf("%d\n", (int)(acos(cos(a) * cos(b) * cos(c) * cos(d) + cos(a) * sin(b) * cos(c) * sin(d) + sin(a) * sin(c)) * 6378.1 + 0.5));
    }
    return 0;
}