#include <iostream>
#include <cmath>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
const double pi = acos(-1);
double rad(double d) {
	return pi / 180 * d;
}
int main(){
	double a, b, c, d;
	const double R = 6378.1;
	while(cin >> a >> b >> c >> d && (a != -1 && b != -1 && c != -1 && c != -1)) {
		a = rad(a);
		b = rad(b);
		c = rad(c);
		d = rad(d);
		cout << floor(R * acos(sin(a)*sin(c) + cos(a)*cos(c)*cos(d-b)) + 0.5) << endl;
	}
	return 0;
}