#include <bits/stdc++.h>
using namespace std;

struct P {
  double x, y, z;
  P() {}
  P(double x, double y, double z) : x(x), y(y), z(z) {}
};

P operator * (const P &a, const double &b) {
  return P(a.x*b, a.y*b, a.z*b);
}
P operator / (const P &a, const double &b) {
  return P(a.x/b, a.y/b, a.z/b);
}

double dot(P a, P b) {
  return a.x*b.x + a.y*b.y + a.z*b.z;
}
double norm(P a) {
  return dot(a,a);
}
double abs(P a) {
  return sqrt(norm(a));
}

double toRad(double deg) {
  return deg/180.0 * M_PI;
}

P getP(double a, double b) {
  P res;
  res.z = sin(a);
  res.x = cos(a) * cos(b);
  res.y = cos(a) * sin(b);
  return res;
}

int main() {
    double a, b, c, d;
  while(cin >> a >> b >> c >> d) {
    if(a == -1 && b == -1 && c == -1 && d == -1) return 0;
    P s = getP(toRad(a),toRad(b));
    P t = getP(toRad(c),toRad(d));
    printf("%.0f\n", acos(dot(s,t)/abs(s)/abs(t))*6378.1);
  }
  return 0;
}