#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF 1<<30

double dtor(double deg) {       // x¨WA
  return deg*M_PI/180;
}
double dist(double x, double y) {
  return sqrt(x*x+y*y);
}

int main() {
  double a,b,c,d;
  while(cin>>a>>b>>c>>d,a!=-1||b!=-1||c!=-1||d!=-1) {
    double bb = dtor(90.0-a);
    double cc = dtor(90.0-c);
    double A = dtor(abs(d-b));
    double res = 6378.1*acos(cos(bb)*cos(cc)+sin(bb)*sin(cc)*cos(A));
    printf("%.0f\n", res);
  }
}