#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<double,double>P;
const double R=6378.1;
const double PI=3.14159265359;
double a,b,c,d;


int main()
{
	for(;scanf("%lf%lf%lf%lf",&a,&b,&c,&d);)
	{
		if(a==-1&&b==-1&&c==-1&&d==-1)break;
		P ang[2];
		vector<P>v;
		vector<double>p[2];
		v.push_back(make_pair(a,b));
		v.push_back(make_pair(c,d));
		for(int i=0;i<2;i++)
		{
			ang[i].first=(v[i].first/180)*PI;
			ang[i].second=(v[i].second/180)*PI;
		}
		for(int i=0;i<2;i++)
		{
			p[i].push_back(R*cos(ang[i].first)*cos(ang[i].second));
			p[i].push_back(R*cos(ang[i].first)*sin(ang[i].second));
			p[i].push_back(R*sin(ang[i].first));
		}
		double dis=sqrt(pow(p[0][0]-p[1][0],2)+pow(p[0][1]-p[1][1],2)+pow(p[0][2]-p[1][2],2));
		double difa=(R*R*2-dis*dis)/(2*R*R);
		double anp=acos(difa);
		double cmp=
		printf("%d\n",(int)(PI*R*(anp/PI)+0.5));
	}
	return 0;
}