#include <bits/stdc++.h>

using namespace std;

const double PI = 3.141592;
const double R = 6378.1;

int main() {
	double N1, E1, N2, E2, Rad;

	while (1) {
		cin >> N1 >> E1 >> N2 >> E2;
		if (N1 == -1 && E1 == -1 && N2 == -1 && E2 == -1) {
			break;
		}

		N1 = N1 * PI / 180.0;
		E1 = E1 * PI / 180.0;
		N2 = N2 * PI / 180.0;
		E2 = E2 * PI / 180.0;

		Rad = R * acos(cos(N1)*cos(N2)*cos(E1 - E2) + sin(N1)*sin(N2));
		cout << round(Rad) << endl;
	}

	return 0;
}
