#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define pi 4*atan(1.0)
#define rep(i,n) for(int i=0;i<n;i++)

double a,b,c,d;

int main(){
	while(cin>>a>>b>>c>>d&&!(a==-1&&b==-1&&c==-1&&d==-1)){
		a*=pi/180;b*=pi/180;c*=pi/180;d*=pi/180;
		double x1=cos(a)*cos(b),Y1=cos(a)*sin(b),z1=sin(a),x2=cos(c)*cos(d),y2=cos(c)*sin(d),z2=sin(c);
		double dist=sqrt((x1-x2)*(x1-x2)+(Y1-y2)*(Y1-y2)+(z1-z2)*(z1-z2));
		printf("%.0f\n",2*asin(dist/2.0)*6378.1);
	}
}