#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  double a,b,c,d,u,v,w,x,y,z;
  while(cin>>a>>b>>c>>d&&a!=-1&&b!=-1&&c!=-1&&d!=-1){
    u=cos(M_PI*b/180)*cos(M_PI*a/180);
    v=sin(M_PI*b/180)*cos(M_PI*a/180);
    w=sin(M_PI*a/180);
    x=cos(M_PI*d/180)*cos(M_PI*c/180);
    y=sin(M_PI*d/180)*cos(M_PI*c/180);
    z=sin(M_PI*c/180);
    cout<<(int)(6378.1*acos(1-((u-x)*(u-x)+(v-y)*(v-y)+(w-z)*(w-z))/2)+0.5)<<endl;
  }
  return 0;
}