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

const double EPS  = 1e-8;
const double r = 6378.1;
const double PI = acos(-1);

int main(){
	double a, b, c, d;
	while( scanf("%lf %lf %lf %lf", &a, &b, &c, &d ) ){
		if( a == -1 && b == -1 && c == -1 && d == -1 ) break;
		
		a = (90.0 - a) * PI / 180.0;
		b = b * PI / 180.0;
		c = (90.0 - c) * PI / 180.0;
		d = d * PI / 180.0;
		
		double x1 = r * sin(a) * cos(b);
		double y1 = r * sin(a) * sin(b);
		double z1 = r * cos(a);
		
		double x2 = r * sin(c) * cos(d);
		double y2 = r * sin(c) * sin(d);
		double z2 = r * cos(c);
		
		double d = (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) + (z1-z2)*(z1-z2);
		int ans = r * acos( 1 - d / (2*r*r) ) + 0.5 + EPS;
		printf("%d\n", ans);
	}
}