#include<iostream>
#include<vector>
#include<cstdio>
#include<cmath>

#define REP(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;

typedef unsigned long long ull;

#define TH(x) (((x)/180.0)*pi)

int main(){
  long double a,b,c,d;
  const long double r  = 6378.1;
  const long double pi = M_PI;
  while(cin>>a>>b>>c>>d, (a!=-1 || b!=-1 || c!=-1 || d!=-1)){
    long double x1,y1,z1,x2,y2,z2,ip,ang;
    a = TH(a); b = TH(b); c = TH(c); d = TH(d);

    x1 = cos(b) * cos(a);
    y1 = sin(b) * cos(a);
    z1 = sin(a);

    x2 = cos(d) * cos(c);
    y2 = sin(d) * cos(c);
    z2 = sin(c);

    ip  = x1*x2 + y1*y2 + z1*z2;
    ang = acos(ip);

    cout << (int)(floor(r*ang+0.5)) << endl;
  }
  return 0;
}