#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){

	const double PI = 2*acos(0.0);
	double a,b,c,d;
	while(cin>>a>>b>>c>>d&&!(a==-1&&b==-1&&c==-1&&d==-1)){
		pair<double,double> angle[2];
		vector<pair<double,double> > v;
		v.push_back(make_pair(a,b));
		v.push_back(make_pair(c,d));
		// pxðWAÉvZ
		for(int i = 0; i < 2; i++){
			angle[i].first=(v[i].first/180)*PI;
			angle[i].second=(v[i].second/180)*PI;
		}
		// ¼a
		const double r=6378.1;
		vector<double> points[2];
		// ÊÀWð»ê¼êßé
		for(int i = 0; i < 2; i++){
			points[i].push_back(r*cos(angle[i].first)*cos(angle[i].second));
			points[i].push_back(r*cos(angle[i].first)*sin(angle[i].second));
			points[i].push_back(r*sin(angle[i].first));
		}
		// 2_Ì¼ü£ðvZ
		double dist = sqrt((points[0][0]-points[1][0])*(points[0][0]-points[1][0])
			+(points[0][1]-points[1][1])*(points[0][1]-points[1][1])
			+(points[0][2]-points[1][2])*(points[0][2]-points[1][2]));
		// ]·èÉæè3ÂÌüªªÈ·cosÌlðßé
		double diffAngle=(r*r+r*r-dist*dist)/(2*r*r);
		// acosÉæècosÌlðÏ·
		double anp = acos(diffAngle);
		// 2*PIÆRÂÌüªªÈ·pxÌäðg¢A£ðßé
		double comp=PI*r*(anp/PI);
		cout<<(int)(comp+0.5)<<endl;
	}

	return 0;
}