#include <stdio.h>
#include <string.h>
#include <math.h>
 
int main(void)
{
    const double radius = 6378.137;
    const double pi = acos(-1);
    double x[2], y[2];
    double dx;
    double d;
     
    while (1){
        int i;
         
        for (i = 0; i < 2; i++){
            scanf("%lf %lf", &y[i], &x[i]);
             
            x[i] = x[i] * pi / 180;
            y[i] = y[i] * pi / 180;
        }
		
		if (x[0] == -1 && x[1] == -1 && y[0] == -1 && y[1] == -1) return 0;
         
        dx = x[1] - x[0];
         
        d = radius * acos( sin(y[0]) * sin(y[1]) + cos(y[0]) * cos(y[1]) * cos(dx) );
         
        printf("%.0f\n", d);
    }
     
    return 0;
}