#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const double PI = acos(-1);
const double EPS = 1e-10;
int sgn(double d) { return d > EPS ? 1 : d < -EPS ? -1 : 0; }

struct Point {
  double x, y, z;
  Point() {}
  Point(const double x, const double y, const double z) : x(x), y(y), z(z) {}
  Point& operator += (const Point other) { x += other.x; y += other.y; z += other.z; return *this; }
  Point& operator -= (const Point other) { x -= other.x; y -= other.y; z -= other.z; return *this; }
  Point& operator *= (const double factor) { x *= factor; y *= factor; z *= factor; return *this; }
  Point& operator /= (const double factor) { x /= factor; y /= factor; z /= factor; return *this; }
  bool operator == (const Point other) { return x == other.x && y == other.x && z == other.z; }
  bool operator != (const Point other) { return !(*this == other); }
};
using Vector = Point;
Point operator + (const Point lhs, const Point rhs) { return Point(lhs.x + rhs.x, lhs.y + rhs.y, lhs.z + rhs.z); }
Point operator - (const Point lhs, const Point rhs) { return Point(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z); }
Point operator * (const Point lhs, const double factor) { return Point(lhs.x * factor, lhs.y * factor, lhs.z * factor); }
Point operator * (const double factor, const Point rhs) { return Point(factor * rhs.x, factor * rhs.y, factor * rhs.z); }
Point operator / (const Point lhs, const double factor) { return Point(lhs.x / factor, lhs.y / factor, lhs.z / factor); }
double operator * (const Point lhs, const Point rhs) { return lhs.x * rhs.x + lhs.y * rhs.y + lhs.z * rhs.z; }
Point operator ^ (const Point lhs, const Point rhs) { return Point(lhs.y * rhs.z - lhs.z * rhs.y, lhs.z * rhs.x - lhs.x * rhs.z, lhs.x * rhs.y - lhs.y * rhs.x); }
double norm(const Point point) { return point * point; }
double abs(const Point point) { return sqrt(norm(point)); }
Point polar(const double r, const double a, const double b) { return Point(r * sin(a) * cos(b), r * sin(a) * sin(b), r * cos(a)); }

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  const double R = 6378.1;
  double a, b, c, d;
  while (cin >> a >> b >> c >> d) {
    if (a == -1 && b == -1 && c == -1 && d == -1) break;
    a /= 180, b /= 180, c /= 180, d /= 180;
    a *= PI, b *= PI, c *= PI, d *= PI;
    Point p = polar(1, PI / 2 - a, b), q = polar(1, PI / 2 - c, d);
    double t = acos(p * q);
    cout << int(round(R * t)) << endl;
  }  

  return 0;
}
