#include<cmath>
using namespace std;
int main(){
	double a,b,c,d, x,y,z,X,Y,Z,d2, k=M_PI/180;
	while(scanf("%lf%lf%lf%lf",&a,&b,&c,&d),a!=-1&&b!=-1&&c!=-1&&d!=-1){
		z=sin(a*k),Z=sin(c*k);
		x=cos(a*k)*cos(b*k),y=cos(a*k)*sin(b*k);
		X=cos(c*k)*cos(d*k),Y=cos(c*k)*sin(d*k);
		d2=(x-X)*(x-X)+(y-Y)*(y-Y)+(z-Z)*(z-Z);
		printf("%.0f\n",acos((2-d2)/2)*6378.1);
	}
	return 0;
}