#include<bits/stdc++.h>
#define FUNC 180.0/(4*atan(1))
using namespace std;
int main(void)
{
	double xy,a,b,c,d,r=6378.1;
	while(1) {
		cin>>a>>b>>c>>d;
		if(a==-1&&b==-1&&c==-1&&d==-1) break;
		a/=FUNC,b/=FUNC,c/=FUNC,d/=FUNC;
		xy=r*(acos(sin(a)*sin(c)+cos(a)*cos(c)*cos(d-b)));
		cout<<(int)(xy+0.5)<<endl;
	}
}