#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())

typedef unsigned long long ull;
const int INF = (int)1e8;
const double PI = acos(-1.0);

string out[] = {"black","blue","lime","aqua","red","fuchsia","yellow","white"};

double Q(double X){return X*X;}

int main(){
	double a,b,c,d;
	while(cin>>a>>b>>c>>d,a>0){
		a = a / 180 * PI;
		b = b / 180 * PI;
		c = c / 180 * PI;
		d = d / 180 * PI;
		double ax,ay,az;
		az = sin(a);
		ax = sqrt(1-az*az) * cos(b);
		ay = sqrt(1-az*az) * sin(b);
		double bx,by,bz;
		bz = sin(c);
		bx = sqrt(1-bz*bz) * cos(d);
		by = sqrt(1-bz*bz) * sin(d);
		double dis = sqrt(Q(ax-bx)+Q(ay-by)+Q(az-bz));
		double arc = asin(dis/2);
		double ans = 2 * 6378.1 * arc;
		int i_ans = (int)floor(ans + 0.5);
		cout << i_ans << endl;
	}
	return 0;
}