#include <stdio.h>
#include <string.h>
#include <math.h>

int main(void)
{
	const double radius = 6378.137;
	const double pi = acos(-1);
	double x[2], y[2];
	double dx;
	double d;
	//double p;
	char str[2048];
	
	while (1){
		int i;
		
		for (i = 0; i < 2; i++){
			scanf("%lf %lf", &y[i], &x[i]);
			
			if (x[i] == -1.0) return (0);
			
			x[i] = x[i] * pi / 180;
			y[i] = y[i] * pi / 180;
		}
		
		dx = x[1] - x[0];
		
		d = radius * acos( sin(y[0]) * sin(y[1]) + cos(y[0]) * cos(y[1]) * cos(dx) );
		//p = 90 - atan2( cos(y[0]) * tan(y[1]) - sin(y[0]) * cos(dx), sin(dx) );
		
		printf("%d\n", (int)(d + 0.5));
	}
	
	return 0;
}