#include <bits/stdc++.h>
using namespace std;
int main(){
	double a,b,c,d;
	while(cin>>a>>b>>c>>d,(b>-0.5)){
		a=a*M_PI/180;
		b=b*M_PI/180;
		c=c*M_PI/180;
		d=d*M_PI/180;
		double x1=cos(a)*cos(b),y1=cos(a)*sin(b),z1=sin(a),x2=cos(c)*cos(d),y2=cos(c)*sin(d),z2=sin(c);
		double n=x1*x2+y1*y2+z1*z2;
		double r1=sqrt(x1*x1+y1*y1+z1*z1);
		double r2=sqrt(x2*x2+y2*y2+z2*z2);
		double rad=acos(n/(r1*r2));
		cout<<(int)(rad*6378.1+0.5)<<endl;
	}
	
	return 0;
}
