#include<bits/stdc++.h>
using namespace std;
typedef long double D;

const D r = 6378.1;
const D PI = acos(-1);

int main(){
  D an, ae, bn, be;
  while(cin >> an >> ae >> bn >> be, ae>=0){
    D n = abs(an - bn);
    D e = abs(ae - be);
    if(e>=180) e = 360 - e;

    D d1 = sqrt( 2*r*r - 2*r*r*cos(n/180 * PI) );
    D d2 = sqrt( 2*r*r - 2*r*r*cos(e/180 * PI) );
    D d3 = sqrt(d1*d1 + d2*d2);
    D s = acos( (2*r*r - d3*d3) / 2*r*r );
    int ans = r*s + 0.5;
    cout << ans << endl;
  }
}