#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

const double PI=3.1415926535;

int main() {
	double a,b,c,d;
	while(cin>>a>>b>>c>>d){
		if(a==-1&&b==-1&&c==-1&&d==-1)break;
		a=a/180*PI;
		b=b/180*PI;
		c=c/180*PI;
		d=d/180*PI;
		cout<<int(acos(cos(PI/2-a)*cos(PI/2-c)+sin(PI/2-a)*sin(PI/2-c)*cos(b-d))*6378.1+0.5)<<endl;;
	}
	return 0;
}