#include <stdio.h>
#include <math.h>

int main(void) {
	int A1,B1,H,M;
	scanf("%d %d %d %d",&A1,&B1,&H,&M);
	double A = (double)A1,B = (double)B1;//時針がAcm,分針がBcm
	double a,b;//aが時針の角度(rad),bが分針の角度(rad)
	a = ((double)H*60 + (double)M) * M_PI /360;
	b = (double)M * M_PI / 30;
	double c;
	if(a == b){
		printf("%.20f\n",B-A);
	}else if(b > a){
		double gumma = b-a;
		c = pow(A,2.0) + pow(B,2.0) - 2.0*A*B*cos(gumma);
		printf("%.20f\n",sqrt(c));
	}else{
		double gumma = a-b;
		c = pow(A,2.0) + pow(B,2.0) - 2.0*A*B*cos(gumma);
		printf("%.20f\n",sqrt(c));
	}
	return 0;
}
