#include <cstdio>
#include <cmath>
#define r 6378.1

int main(void){
	double a,b,c,d;
	while(1){
		scanf("%lf %lf %lf %lf",&a,&b,&c,&d);
		if(b+d<-1.0)break;
		a=90.0-a;
		c=90.0-c;
		double x1=cos(b*M_PI/180.0)*sin(a*M_PI/180.0);
		double x2=cos(d*M_PI/180.0)*sin(c*M_PI/180.0);
		double y1=sin(b*M_PI/180.0)*sin(a*M_PI/180.0);
		double y2=sin(d*M_PI/180.0)*sin(c*M_PI/180.0);
		double z1=cos(a*M_PI/180.0);
		double z2=cos(c*M_PI/180.0);
		double e=sqrt(pow(x1-x2,2.0)+pow(y1-y2,2.0)+pow(z1-z2,2.0));
		double ang=acos(1.0-e*e/2.0);
		printf("%d\n",(int)(r*ang+0.5));
	}
	return 0;
}