#include<cstdio>
#include<cmath>

using namespace std;

const double PI=3.14159265358979323846264;
const double eps=1e-9;

struct Point{
	double x,y,z;
	Point(){}
	Point(double a,double b,double c):x(a),y(b),z(c){
//		printf("%f %f %f\n",x,y,z);
	}
};

Point getP(double e,double n)
{
	double theta=PI*e/180,phi=PI*n/180;
	double x1=cos(theta),y1=sin(theta);
	return Point(x1*cos(phi),y1*cos(phi),sin(phi));
}

double getAngle(Point p1,Point p2)
{
	double d=p1.x*p2.x+p1.y*p2.y+p1.z*p2.z;
	return acos(d);
}

double solve(double e1,double n1,double e2,double n2)
{
	Point p1=getP(e1,n1),p2=getP(e2,n2);
	double ang=getAngle(p1,p2);
//	printf("%f\n",ang);
	double res=6378.1*ang;
	return res;
}

int main()
{
	while(true)
	{
		double e1,n1,e2,n2;
		scanf("%lf%lf%lf%lf",&n1,&e1,&n2,&e2);
		if(e1==-1&&n1==-1&&e2==-1&&n2==-1) break;
		printf("%d\n",(int)(solve(e1,n1,e2,n2)+0.5));
	}
	return 0;
}