#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
int main(){
	double a,b,c,d;
	double PI=3.14159265359;
	while(scanf("%lf%lf%lf%lf",&a,&b,&c,&d),b>-0.5){
		double x=cos(a*PI/180)*sin(b*PI/180)-cos(c*PI/180)*sin(d*PI/180);
		double y=cos(a*PI/180)*cos(b*PI/180)-cos(c*PI/180)*cos(d*PI/180);
		double z=sin(a*PI/180)-sin(c*PI/180);
		printf("%.0f\n",6378.1*2.0*asin(sqrt(x*x+y*y+z*z)/2));
	}
}