#include<iostream>
#include<cmath>

double toDegree(double a){
	return M_PI / 180 * a;
}

int main(){
	const double R = 6378.1;
	double a, b, c, d;
	while(std::cin >> a >> b >> c >> d, a != -1){
		//弧度法に変換
		a = toDegree(a);
		b = toDegree(b);
		c = toDegree(c);
		d = toDegree(d);
		double delta_x = d-b,
			dist = R*acos(sin(a)*sin(c)+cos(a)*cos(c)*cos(delta_x));
		std::cout << static_cast<int>(dist+0.5) << std::endl;
	}
}