#include <iostream>
#include <cmath>

#define calc(x, y) (M_PI*(y-x)/180.0)

using namespace std;

double a, b, c, d;

double solve()
{
  double s = calc(a, 90.0), t = calc(c, 90.0), u = cos(calc(b, d));

  return acos(cos(s)*cos(t)+sin(s)*sin(t)*u);
}

int main()
{
  while(cin>>a>>b>>c>>d && !(a == -1 && b == -1 && c == -1 && d == -1)){
    cout << (int)(6378.1*solve()) << endl;
  }
	
  return 0;
}