#include <iostream>
#include <cmath>

using namespace std;

#define R 6378.1
#define PI 3.1415926535

int main() {
	double a, b, c, d;
	while (cin >> a >> b >> c >> d) {
		if (a == -1 && b == -1 && c == -1 && d == -1) {
			break;
		}
		double x1, y1, z1, x2, y2, z2;
		x1 = R * cos((a/360.0)*2.0*PI) * cos((b/360.0)*2.0*PI);
		y1 = R * cos((a/360.0)*2.0*PI) * sin((b/360.0)*2.0*PI);
		z1 = R * sin((a/360.0)*2.0*PI);
		x2 = R * cos((c/360.0)*2.0*PI) * cos((d/360.0)*2.0*PI);
		y2 = R * cos((c/360.0)*2.0*PI) * sin((d/360.0)*2.0*PI);
		z2 = R * sin((c/360.0)*2.0*PI);
		double r = sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1));
		double t = R * acos((R*R+R*R-r*r)/(2.0*R*R));
		double tt = t - (int)t;
		if (tt >= 0.5) {
			t += 1.0;
		}
		cout << (int)t << endl;
	}
	return 0;
}