#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    double a, b, c, d;
    /*a:第１都市の北緯
      b:第１都市の東経
      c:第２都市の北緯
      d:第２都市の東経*/
    
    while(true){
        cin >> a >> b >> c >> d;
        if(a == -1.0 && b == -1.0 && c == -1.0 && d == -1.0) break;

        double tha = M_PI * a / 180;
        double thb = M_PI * b / 180;
        double thc = M_PI * c / 180;
        double thd = M_PI * d / 180;

        double d = acos(sin(tha) * sin(thc) + cos(tha) * cos(thc) * cos(thd - thb));
        cout << (int)(6378.1 * d + 0.5) << endl;
    }
    return 0;
}

