#include <iostream>
#include <cmath>
using namespace std;

int main()
{
	double a, b, c, d;
	const double pi = 3.141592653589793;

	cin >> a >> b >> c >> d;

	while (a != -1 || b != -1 || c!= -1 || d != -1) {
		double u[3], v[3];

		u[0] = cos(b * pi / 180) * cos(a * pi / 180);
		u[1] = sin(b * pi / 180) * cos(a * pi / 180);
		u[2] = sin(a * pi / 180);

		v[0] = cos(d * pi / 180) * cos(c * pi / 180);
		v[1] = sin(d * pi / 180) * cos(c * pi / 180);
		v[2] = sin(c * pi / 180);

		cout << round(acos(u[0] * v[0] + u[1] * v[1] + u[2] * v[2]) * 6378.1) << endl;
		
		cin >> a >> b >> c >> d;
	}

	return 0;
}

