#include<iostream>
#include<cmath>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

typedef struct{double x,y,z;} P;

const double R = 6378.1;
const double PI = acos(-1);


P calc(double a,double b){
  double z = R*sin(a);
  double x = R*cos(a)*cos(b),y=R*cos(a)*sin(b);
  return (P){x,y,z};
}

double dist(double a,double b,double c){
  return sqrt(a*a+b*b+c*c);
}

double rad(double sdist){
  double c = (R*R+R*R-sdist*sdist)/(2*R*R);
  return acos(c);
}

main(){
  
  while(true){
    P in[2];
    rep(i,2){
      double a,b;
      cin>>a>>b;
      if (a == -1)return false;
      a=a/180*PI;b=b/180*PI;
      in[i]=calc(a,b);
    }
    
    double sdist=dist(in[0].x-in[1].x,in[0].y-in[1].y,in[0].z-in[1].z);
    double trad =rad(sdist);
   

    double cdist=trad*R;
    printf("%.0lf\n",cdist);
    
  }
  return false;
}