#define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>
#include <ctime>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF = 1 << 30;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;
const int CLK = CLOCKS_PER_SEC;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)

int main(){
	double la[2], lo[2];
	while(cin >> la[0] >> lo[0] >> la[1] >> lo[1] && (abs(la[0] + 1) > EPS 
		|| abs(la[1] + 1) > EPS || abs(lo[0] + 1) > EPS || abs(lo[1] + 1) > EPS)){

	
		double x[2], y[2], z[2];
		rep(i, 2){
			la[i] *= (M_PI) / 180.0;
			lo[i] *= (M_PI) / 180.0;
		}
		rep(i, 2){
			z[i] = sin(la[i]);
			y[i] = cos(la[i]) * sin(lo[i]);
			x[i] = cos(la[i]) * cos(lo[i]);
		}
		double dis = sqrt((x[0]-x[1])*(x[0]-x[1])+(y[0]-y[1])*(y[0]-y[1])+(z[0]-z[1])*(z[0]-z[1]));
		double theta = asin(dis/2);
		double res = theta * 2;
		cout << (int)(res * 6378.1 + 0.5) << endl;
	}
	return 0;
}