include Math
R=6378.1
(x,y,z=$_.split.map{|i|i.to_f*PI/180}.each_slice(2).map{|h,l|[cos(l)*r=cos(h)*R,sin(h)*R,sin(l)*r]}.inject(&:zip).map{|i,j|i-j}
p (R*acos(1-(hypot(hypot(x,y),z)/R)**2/2)).round)while gets>?.