// 2011/08/21 Tazoe

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
	while(true){
		double a, b, c, d;
		cin >> a >> b >> c >> d;
		if(a==-1.0&&b==-1.0&&c==-1.0&&d==-1.0)
			break;

		// ツδ可ジツアツδ督づ可陛渉環キ
		a = a*M_PI/180.0;
		b = b*M_PI/180.0;
		c = c*M_PI/180.0;
		d = d*M_PI/180.0;

		double x = acos(sin(a)*sin(c)+cos(a)*cos(c)*cos(d-b));

		cout << (int)(6378.1*x+0.5) << endl;		// ツ渉ャツ青板点ツ暗按可コツづーツ四ツ偲個古慊禿シ
	}

	return 0;
}