#include <iostream>
#include <cmath>
#define PI 3.14159265
using namespace std;
double theta[2],phi[2];

void solve() {
  double OC1[3],OC2[3],psai;
  for(int i=0;i<2;i++) {
    theta[i] *= PI/180;
    phi[i] *= PI/180;
  }

  OC1[0] = cos(phi[0]) * cos(theta[0]);
  OC1[1] = cos(phi[0]) * sin(theta[0]);
  OC1[2] = sin(phi[0]);
  OC2[0] = cos(phi[1]) * cos(theta[1]);
  OC2[1] = cos(phi[1]) * sin(theta[1]);
  OC2[2] = sin(phi[1]);
  double inter=0;

  for(int i=0;i<3;i++) {
    inter += OC1[i]*OC2[i];
  }

  psai = acos(inter);
  double dist = psai*6378.1;
  dist+=0.5;
  int ans = (int)floor(dist);
  cout << ans << endl;

}

int main() {
  while(cin >> phi[0] >> theta[0] >> phi[1] >> theta[1]) {
    if(theta[0] == -1 && phi[0] == -1 && theta[1] == -1 && phi[1] == -1) break;
    solve();
  }
}