#include<math.h>
#include<iostream>
using namespace std;

#define PI 3.141592

int main(){
  long double d1,d2,e1,e2;

  while(1){
    cin>>d1>>e1>>d2>>e2;

    if(d1==-1&&d2==-1&&e1==-1&&e2==-1) break;

    long double d = acos(sin(d1*PI/180)*sin(d2*PI/180)
			 + cos(d1*PI/180)*cos(d2*PI/180)*cos((e1-e2)*PI/180) );

    cout<<floor(d*6378.1+0.5)<<endl;
  }
}