#include<iostream>
#include<cmath>
#define PI 3.141592
using namespace std;

int main(){
  double a,b,c,d;
  double seta;

  while(1){
    cin >> a >> b >> c >> d;
    if(a==-1 && b==-1 && c==-1 && d==-1)break;

    a *= PI / 180;
    b *= PI / 180;
    c *= PI / 180;
    d *= PI / 180;
    seta = acos( cos(a)*cos(c)*cos(b-d)+sin(a)*sin(c) );
    cout << (int)(6378.1 * seta + 0.5) << endl;

  }
}