#include <iostream>
#include <cmath>

#define RADIUS 6378.1

double ground_dist(double a, double b, double c, double d)
{
	a *= M_PI / 180.0; b *= M_PI / 180.0; c *= M_PI / 180.0; d *= M_PI / 180.0;
	return RADIUS * std::acos(std::sin(a)*std::sin(c) + std::cos(a)*std::cos(c)*std::cos(d-b));
}

int main()
{
	double a, b, c, d;
	while (true) {
		std::cin >> a >> b >> c >> d;
		if (a==-1 && b==-1 && c==-1 && d==-1) break;
		//if (b>d && b-d > 180) b = 360 - b;
		//else if (d>b && d-b > 180) d = 360 - d;
		std::cout << std::round(ground_dist(a, b, c, d)) << std::endl;
	}
	return 0;
}

