#include <iostream>
#include <cmath>

#define PI 3.14159265358979
#define RADIUS 6378.1 // 単位km

#define DEG_TO_RAD(theta) theta * PI / 180.0

struct position {
	double lat; // 緯度
	double lon; // 経度
	// 以下直交座標系
	double x;
	double y;
	double z;
};

void getCoordinates(position& loc)
{
	loc.x = RADIUS * cos(DEG_TO_RAD(loc.lat)) * cos(DEG_TO_RAD(loc.lon));
	loc.y = RADIUS * cos(DEG_TO_RAD(loc.lat)) * sin(DEG_TO_RAD(loc.lon));
	loc.z = RADIUS * sin(DEG_TO_RAD(loc.lat));
}

double getOneLineDistance(const position& loc1, const position& loc2)
{
	return sqrt(pow(loc1.x-loc2.x, 2) + pow(loc1.y - loc2.y, 2) + pow(loc1.z - loc2.z, 2));
}

double getInteriorAngle(double oneLineDistance)
{
	return 2 * asin(oneLineDistance/2/RADIUS);
}

double getSurfaceDistance(position& loc1, position& loc2)
{
	getCoordinates(loc1);
	getCoordinates(loc2);
	return RADIUS * getInteriorAngle(getOneLineDistance(loc1, loc2));
}

int main(void)
{
	position loc1, loc2;

	while(1) {
		std::cin >> loc1.lat >> loc1.lon >> loc2.lat >> loc2.lon;
		if(loc1.lat == -1 && loc1.lon == -1 && loc2.lat == -1 && loc2.lon == -1) {
			break;
		}
		std::cout << (int)(getSurfaceDistance(loc1, loc2) + 0.5) << std::endl;
	}

	return 0;
}