#include<stdio.h>
#include<math.h>
const double R=6378.1;
double n1,w1,n2,w2;
long double cer=2*R*3.141592;
double min(double a,double b){return a<b?a:b;}
double max(double a,double b){return a>b?a:b;}
int main()
{
	for(;scanf("%lf%lf%lf%lf",&n1,&w1,&n2,&w2);)
	{
		if(n1==-1&&w1==-1&&n2==-1&&w2==-1)
			break;
		double a1=(max(n1,n2)-min(n1,n2));
		double a2=(max(w1,w2)-min(w1,w2));
		a1=min(a1,360.0-a1);
		a2=min(a2,360.0-a2);
		long double l1=cer*(a1/360);
		long double l2=cer*(a2/360);
		printf("%.0f\n",sqrt(l1*l1+l2*l2));
	}
	return 0;
}