#include<stdio.h>
#include<math.h>
#define pi 3.14159265358979323846

double sphere_distance(double x1, double y1, double z1, double x2, double y2, double z2){
	double r, o1, o2, f1, f2;
	r = pow(x1*x1+y1*y1+z1*z1, 0.5);
	o1 = acos(z1/r);
	o2 = acos(z2/r);
	f1 = atan2(y1,x1);
	f2 = atan2(y2,x2);
	
	printf("r is: %lf\n", r); 
	printf("o1 is: %lf\n", o1); 
	printf("o2 is: %lf\n", o2); 
	printf("f1 is: %lf\n", f1); 
	printf("f2 is: %lf\n", f2); 
	
	return r*acos(cos(o1)*cos(o2)+sin(o1)*sin(o2)*cos(f1-f2));
}

int main(){
	double x1,y1,z1,x2,y2,z2;
	scanf("%lf %lf %lf\n %lf %lf %lf", &x1, &y1, &z1, &x2, &y2, &z2);
	printf("distance is: %lf", sphere_distance(x1,y1,z1,x2,y2,z2));
	return 0;
}