#include <cstdio>
#include <cmath>

using namespace std;

int main()
{
	double a, b, c, d;
	
	while (scanf("%lf %lf %lf %lf", &a, &b, &c, &d) && b >= -0.5){
		if (b > 180) b = b - 360;
		if (d > 180) d = d - 360;
		
		a = a * M_PI / 180;
		c = c * M_PI / 180; 
		printf("%d\n", (int)round(6378.1 * acos(sin(a) * sin(c) + cos(a) * cos(c) * cos((d - b) * M_PI / 180))));
	}
	return (0);
}