#include<iostream>
#include<cmath>
#include<cstdio>
#define earth 6378.1
using namespace std;
int main(){
	double n1, n2, e1, e2;
	while(cin >> n1 >> e1 >> n2 >> e2){
		if(n1==-1&&n2==-1&&e1==-1&&e2==-1) break;
		double disAB, disBC, disCA, cosC;
		disBC = M_PI*(90-n1)/180;
		disCA = M_PI*(90-n2)/180;
		cosC = cos(M_PI*(e2-e1)/180);
		disAB = acos(cos(disBC)*cos(disCA)+sin(disBC)*sin(disCA)*cosC);
		printf("%.f\n",(disAB*earth));
	}
	return 0;
}