#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef pair<double, double> P;
typedef pair<P, double> PP;
const double R = 6378.1;

void inputP(P &p){
  double x, y; cin >>x >>y;
  p = P(x, y);
}

PP make_pp(P &p){
  PP res;
  res.first.first = R * cos(p.first) * cos(p.second);
  res.first.second = R * cos(p.first) * sin(p.second);
  res.second = R * sin(p.first);
  return res;
}

double distancePP(PP &a, PP &b){
  double x = a.first.first - b.first.first;
  double y = a.first.second - b.first.second;
  double z = a.second - b.second;
  return sqrt(x * x + y * y + z * z);
}
 
int main() {
  P a, b;
  while(cin >>a.first >>a.second >>b.first >>b.second && a != P(-1, -1) && b != P(-1, -1)){
  a.first = a.first / 180.0 * M_PI;
  a.second = a.second/ 180.0 * M_PI;
  b.first = b.first / 180.0 * M_PI;
  b.second = b.second / 180.0 * M_PI;
  PP pa = make_pp(a), pb = make_pp(b);
  double l = distancePP(pa, pb), r = (R * R + R * R - l * l) / (2 * R * R);
  cout <<(int)round(acos(r) * R) <<endl;
  }
  return 0;
}