#include <iostream>
#include <math.h>

using namespace std;

int main() {
	int i;
	double px[2],py[2],pz[2],x[2],y[2],len,s,pi=3.141592;
	while(cin >> y[0]) {
		if (y[0]==-1) break;
		cin >> x[0] >> y[1] >> x[1];
		for (i=0;i<2;i++) {
			px[i]=cos(pi*y[i]/180); pz[i]=sin(pi*y[i]/180);
			py[i]=sin(pi*x[i]/180)*px[i]; px[i]=cos(pi*x[i]/180)*px[i];
		}
		len=sqrt((px[0]-px[1])*(px[0]-px[1])+(py[0]-py[1])*(py[0]-py[1])+(pz[0]-pz[1])*(pz[0]-pz[1]));
		s=acos(1-len*len/2);
		cout << (int)(6378.1*s+0.5) << endl;
	} 
	return 0;
}