#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int main() {
	double a, b, c, d;
	while (1) {
		scanf("%lf%lf%lf%lf", &a, &b, &c, &d);
		if (a == -1 && b == -1 && c == -1 && d == -1)break;
		a = a / 180 * M_PI; b = b / 180 * M_PI; c = c / 180 * M_PI; d = d / 180 * M_PI;
		double e = sin(a)*sin(c) + cos(a)*cos(c)*cos(b - d);
		e = acos(e);
		printf("%d\n", (int)round(e*6378.1));
	}
}