#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
using namespace std;

const int INF = 1e9;
typedef long long ll;

int main(void){
  double lat1, lat2, lng1, lng2;
  const double r = 6378.1, pi = 3.1415926535;
  while(cin >> lat1 >> lng1 >> lat2 >> lng2 && lat1 != -1 && lng1 != -1 && lat2 != -1 && lng2 != -1){
    double x1, y1, z1, x2, y2, z2;
    double len1, len2, theta;
    x1 = r * cos(lat1 * pi / 180) * cos(lng1 * pi / 180);
    x2 = r * cos(lat2 * pi / 180) * cos(lng2 * pi / 180);
    y1 = r * cos(lat1 * pi / 180) * sin(lng1 * pi / 180);
    y2 = r * cos(lat2 * pi / 180) * sin(lng2 * pi / 180);
    z1 = r * sin(lat1 * pi / 180);
    z2 = r * sin(lat2 * pi / 180);
    len1 = sqrt(x1 * x1 + y1 * y1 + z1 * z1);
    len2 = sqrt(x2 * x2 + y2 * y2 + z2 * z2);
    theta = acos((x1 * x2 + y1 * y2 + z1 * z2) / (len1 * len2));
    cout << int(r * theta + 0.5)<< endl;
  }
  return 0;
}