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

double deg_rad(int x)
{
	return x*M_PI/180.0;
}
int abs(int x)
{
	if (x<0)
		return x*-1;
	else
		return x;
}
int main()
{
	int A, B, H, M;
	int angle;
	double angle_rad, C;
	scanf("%d %d %d %d",&A,&B,&H,&M);
	angle = abs((5*H-M)*6);
	angle_rad = deg_rad(angle);
	C = sqrt(A*A + B*B - A*B*cos(angle_rad));
	printf("%g",C);
	return 0;
	
}