#include<iostream>
#include<cmath>

using namespace std;

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

const double PI = acos(-1);

int main() {
  double a, b, c, d;
  while (true) {
    cin >> a >> b >> c >> d;
    if (a == -1 && b == -1 && c == -1 && d == -1) break;
    a *= PI / 180;
    b *= PI / 180;
    c *= PI / 180;
    d *= PI / 180;
    cout << int(6378.1 * acos(cos(PI / 2 - a) * cos(PI / 2 - c) + cos(b - d) * sin(PI / 2 - a) * sin(PI / 2 - c)) + 0.5) << endl;
  }
  return 0;
}