#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>

const double Eps = 1e-8;
const double PI = 4*atan(1.0);
double to_radian(double degree)
{
	return degree*PI/180;
}
using namespace std;

int main()
{
	const double Radius = 6378.1;
	double a[2], b[2];
	while (scanf("%lf %lf %lf %lf", a, b, a+1, b+1), *b >= 0)
	{
		double x[2], y[2], z[2];
		for (int i = 0; i < 2; ++i)
		{
			a[i] = to_radian(a[i]);
			b[i] = to_radian(b[i]);
			x[i] = cos(a[i])*cos(b[i]);
			y[i] = cos(a[i])*sin(b[i]);
			z[i] = sin(a[i]);
		}
		double cs = (x[0]*x[1]+y[0]*y[1]+z[0]*z[1]);
		double angle = acos(cs);
		double ans = Radius * angle + 0.5 + Eps;

		printf("%d\n", (int)ans);
	}

	return 0;
}