#include <iostream>
#include <cmath>

using namespace std;

#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,n) FOR(i,0,n)

const double PI = acos(-1);

double angToRad(double angle) {
	return angle * PI / 180.0;
}

int main() {
	double a, b, c, d;
	while (cin >> a >> b >> c >> d, a != -1.0 || b != -1.0 || c != -1.0 || d != -1.0) {
		a = angToRad(a);
		b = angToRad(b);
		c = angToRad(c);
		d = angToRad(d);
		int ans = round(6378.1 * acos(sin(a) * sin(c) + cos(a) * cos(c) * cos(d - b)));
		cout << ans << endl;
	}
	return 0;
}