#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){
    if(ae>180) ae -= 360;
    if(be>180) be -= 360;

    double s = acos( sin(an)*sin(bn) + cos(an)*cos(bn)*cos(ae-be) ); 
    int ans = r*s + 0.5;
    cout << ans << endl;
  }
}