
public class Main {

    public static void main(String[] args) {
        System.out.print(calculateGeographicalDistance(38.24, 20.42, 37.51, 15.17));
    }
    
    public static int calculateGeographicalDistance(double latitude1, double longitude1, 
            double latitude2, double longitude2)
    {
        latitude1 = convertDegreeToRadian(latitude1);
        longitude1 = convertDegreeToRadian(longitude1);
        latitude2 = convertDegreeToRadian(latitude2);
        longitude2 = convertDegreeToRadian(longitude2);
       
        double RRR = 6378.388; 
        double q1 = Math.cos( longitude1 - longitude2);
        double q2 = Math.cos( latitude1 - latitude2);
        double q3 = Math.cos( latitude1 + latitude2);
        int dij = (int) ( RRR * Math.acos( 0.5*((1.0+q1)*q2 - (1.0-q1)*q3) ) + 1.0);
        return dij;
    }
    
    public static double convertDegreeToRadian(double degree)
    {
        int deg = (int) degree;
        double min = degree - deg;
        double radian = Math.PI * (deg + 5.0 * min / 3.0 ) / 180.0; 
        return radian;
    }
}
