#include <stdio.h>

#include <string.h>

#include <math.h>

#define pi acos(-1)

char s[1005];

int main(){

	int a,b,h,m;
	scanf("%d%d%d%d",&a,&b,&h,&m);

	double are=30.0*h-5.5*m;

	double c=sqrt(1.0*a*a+1.0*b*b-2.0*a*b*cos(are/180*pi));

	printf("%.11lf\n",c);

	return 0;

}