#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <sstream>
#include <cmath>

using namespace std;

int main(){
	
	while(true){
		
		double a, b, c, d;;
		
		cin >> a >> b >> c >> d;
		
		if(b < 0 || d < 0){
			break;
		}
		
		a = a * M_PI / 180;
		b = b * M_PI / 180;
		c = c * M_PI / 180;
		d = d * M_PI / 180;
		
		double x1, y1, z1, x2, y2, z2;
		
		x1 = cos(a) * cos(b);
		y1 = sin(a);
		z1 = cos(a) * sin(b);
		x2 = cos(c) * cos(d);
		y2 = sin(c);
		z2 = cos(c) * sin(d);
		
		double dist_linear_2 = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) + (z1 - z2) * (z1 - z2);
		
		double dist_rad = acos((2 - dist_linear_2) / 2);
		
		int dist = (int)(dist_rad * 6378.1 + 0.5);
		
		cout << dist << endl;
	}
	
	return 0;
}