#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>
#include <cstdio>
#include <cmath>
#include <complex>
#include <iostream>
#include <iterator>

using namespace std;

#define reep(i,f,t) for(int i=f ; i<int(t) ; ++i)
#define rep(i,n) reep(i, 0, n) 
#define sq(a) ((a)*(a))

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main()
{
	double a, b, c, d;
	while(scanf("%lf%lf%lf%lf", &a, &b, &c, &d), a!=-1.0&&b!=-1.0&&c!=-1.0&&d!=-1.0){
		a *= M_PI / 180.0;
		b *= M_PI / 180.0;
		c *= M_PI / 180.0;
		d *= M_PI / 180.0;
		printf("%d\n", (int)(6378.1*acos(cos(a)*cos(b)*cos(c)*cos(d)+sin(a)*sin(c)+cos(a)*sin(b)*cos(c)*sin(d))+0.5));
	}
}