#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <stack>
#include <vector>
#include <math.h>
#include <queue>

using namespace std;

//I read this web page.
// http://krdlab.hatenablog.com/entry/20060322

int main(){

	double a,b,c,d,ans,r=6378.1;
	double value,x1,y1,z1,x2,y2,z2,distance;

	while(true){
		scanf("%lf %lf %lf %lf",&a,&b,&c,&d);
		if(a == -1 && b == -1 && c == -1 && d == -1)break;

		x1 = r*cos(b*M_PI/180)*cos(a*M_PI/180);
		y1 = r*sin(b*M_PI/180)*cos(a*M_PI/180);
		z1 = r*sin(a*M_PI/180);

		x2 = r*cos(d*M_PI/180)*cos(c*M_PI/180);
		y2 = r*sin(d*M_PI/180)*cos(c*M_PI/180);
		z2 = r*sin(c*M_PI/180);

		distance = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2));

		value = acos(1 - (distance*distance)/(2*r*r));

		ans = r*value;

		printf("%.0lf\n",round(ans));

	}

	return 0;
}