#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	double a,b,c,d;
	const double r = 6378.1;
	const double p = 3.14159265;
	cin >> a >> b >> c >> d;
	if(a==-1&&b==-1&&c==-1&&d==-1)break;
	a *= p / 180.0;
	b *= p / 180.0;
	c *= p / 180.0;
	d *= p / 180.0;
	/*
	if(b > 180.0) b -= 360.0;
	if(d > 180.0) d -= 360.0;
	if(a < c) swap(a,c);
	if(b < d) swap(b,d);
	*/
	double ans;
	double s = acos( cos(a) * cos(c) * cos(b - d) + sin(a)*sin(c) );
	ans = r * s;
	printf("%.f\n",ans);

    }
    return 0;
}