#include <iostream>
#include <cmath>

using namespace std;

int main()
{
	const double r = 6378.1; // ツ地ツ仰づ個板シツ径
	double a, b, c, d;

	while (cin >> a >> b >> c >> d && a != -1. && b != -1. && c != -1. && d != -1. ){
		a *= M_PI/180.; b *= M_PI/180.; c *= M_PI/180.; d *= M_PI/180.;
		double e = sin (a)*sin(c) + cos(a)*cos(c)*cos(b-d);
		int res = (int)(r*acos(e ) + 0.5);
		cout << res << endl;

	} // end loop

	return 0;
}