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

const double EPS = 1e-9;

int main() {
	double theta, phi, rad;
	double a, b, c, d;

	while(1) {
		cin >> a >> b >> c >> d;
		if(fabs(4 + (a + b + c + d)) < EPS)
			break;

		double x0, y0, z0, x1, y1, z1;
		z0 = sin(a * M_PI / 180.0);
		x0 = cos(a * M_PI / 180.0) * cos(b * M_PI / 180.0);
		y0 = cos(a * M_PI / 180.0) * sin(b * M_PI / 180.0);
		z1 = sin(c * M_PI / 180.0);
		x1 = cos(c * M_PI / 180.0) * cos(d * M_PI / 180.0);
		y1 = cos(c * M_PI / 180.0) * sin(d * M_PI / 180.0);

		double dist = ((x1 - x0)*(x1 - x0) + (y1 - y0)*(y1 - y0) + (z1 - z0)*(z1 - z0));
		double rad;
		double r = 6378.1;

		rad = acos(max(1.0 - dist / 2.0, -1.0));
		cout << (int)(r * rad + 0.5) << endl;
	}
}