#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007

//qsort用、昇順
int compare_int(const void *a, const void *b)
{
	return *(int*)a-*(int*)b;
}
//qsort(data, 10, sizeof(int), compare_int)

int main(){
	double a, b, h, m;
	scanf("%lf%lf%lf%lf", &a, &b, &h, &m);
	double theta = fabs(11*m-60*h);
	//printf("%f\n", theta);
	double cosx = cos(theta*PI/360);
	//printf("%f\n", cosx);
	//printf("%f, %f, %f\n", a*a, b*b, 2*a*b*cosx);
	double ans = sqrt(a*a - 2*a*b*cosx + b*b);
	printf("%lf\n", ans);
	
	return 0;
}