#include <cstdio>
#include <cmath>
using namespace std;

void pos(double a, double b, double x[3]) {
  double aa, bb;
  aa = a * M_PI / 180.;
  bb = b * M_PI / 180.;
  x[0] = cos(aa)*cos(bb);
  x[1] = cos(aa)*sin(bb);
  x[2] = sin(aa);
}

int main() {
  double a, b, c, d, x[3], y[3], dot, t;
  int ans;
  while (1) {
    scanf("%lf %lf %lf %lf", &a, &b, &c, &d);
    if (a == -1 && b == -1 && c == -1 && d == -1) break;
    pos(a, b, x);
    pos(c, d, y);
    dot = x[0]*y[0]+x[1]*y[1]+x[2]*y[2];
    if (dot < -1.) dot = -1.;
    else if (dot > 1.) dot = 1.;
    t = acos(dot);
    ans = (int)round(t * 6378.1);
    printf("%d\n", ans);
  }
  return 0;
}