//04
#include<iostream>
#include<cmath>

using namespace std;

#define PI acos(-1)
#define R 6378.1
#define S(X) ((X)*(X))

int main(){
  for(;;){
    double x[2],y[2],z[2];
    for(int i=0;i<2;i++){
      double a,b;
      cin>>a>>b;
      if(a==-1&&b==-1)return 0;
      y[i]=R*sin(a/180*PI);
      x[i]=R*cos(a/180*PI)*cos(b/180*PI);
      z[i]=R*cos(a/180*PI)*sin(b/180*PI);
    }
    cout<<int(2*R*asin(sqrt(S(x[0]-x[1])+S(y[0]-y[1])+S(z[0]-z[1]))/2/R)+.5)<<endl;
  }
  return 0;
}