#include <iostream>
#include <cmath>
#define R 6378.1
#define PI 4*atan(1.0)
#define deg PI/180
using namespace std;
int main(){
	double a,b,c,d;
	while(cin>>a>>b>>c>>d){
		if(a==-1&&b==-1&&c==-1&&d==-1)break;
		double theta = acos(cos(a*deg)*cos(c*deg)*cos((d-b)*deg) + sin(a*deg)*sin(c*deg));
		cout<<round(R*theta)<<"\n";
	}
	return 0;
}