#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define EPS 1e-10
#define PI acos(-1)
#define R 6378.1

using namespace std;

struct P
{
	double x,y,z;

	double distance(const P& o)
	{
		return sqrt( (x-o.x)*(x-o.x) + (y-o.y)*(y-o.y) + (z-o.z)*(z-o.z) );
	}
};

double toRad(double a)
{
	return (a/180)*PI;
}

int main()
{
	double a,b,c,d;
	while(cin >> a >> b >> c >> d)
	{
		if(a == -1 && b == -1 && c == -1 && d == -1) break;

		P p[2];

		p[0].x = R*cos(toRad(a))*cos(toRad(b));
		p[0].y = R*cos(toRad(a))*sin(toRad(b));
		p[0].z = R*sin(toRad(a));

		p[1].x = R*cos(toRad(c))*cos(toRad(d));
		p[1].y = R*cos(toRad(c))*sin(toRad(d));;
		p[1].z = R*sin(toRad(c));

		double angle = acos((R*R + R*R - p[0].distance(p[1])*p[0].distance(p[1])) / (2*R*R));
		cout << (int)(PI*R*(angle/PI) + 0.5) << endl;

	}
	return 0;
}