#include <iostream>
#include <cmath>
using namespace std;

double dtor(double deg){
	return deg*M_PI/180.0;
}

int main() {
	double a,b,c,d;
	double r = 6378.1;
	
	while(cin>>a>>b>>c>>d,(int)(a+1)|(int)(b+1)|(int)(c+1)|(int)(d+1)){
		double distance = r*acos(sin(dtor(a))*sin(dtor(c))+cos(dtor(a))*cos(dtor(c))*cos(dtor(b-d)));
		
		cout<<round(distance)<<endl;
		
	}
	
	
	
	return 0;
}