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

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

D pow2(D a){
  return a*a;
}

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

    int ans = sqrt( pow2(n*r) + pow2(e*r*cos(p)) ) + 0.5;
    cout << ans << endl;
  }
}