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

int main(void)
{
	int A,B,H,M;
	double c,Ha,Ma,answer,t;
	scanf("%d",&A);
	scanf("%d",&B);
	scanf("%d",&H);
	scanf("%d",&M);
	Ma=(double)M*360/60;
	Ha=(double)H*360/12+Ma/12;
	if(Ha>Ma)c=(double)(Ha-Ma)*3.14159265359/180;
	else c=(double)(Ma-Ha)*3.14159265359/180;
	t=cos(c)*A*B*2;
	answer=(double)sqrt(A*A+B*B-t);
	printf("%.9f",answer);
	return 0;
}