#include<stdio.h>
#include <math.h>
#define pai 3.14159265
int main(void)
{
	long test;
	long A, B, as, bs;
	long H, M;
	long angH, angM;
	double sa;
	double kai;

	test = scanf("%ld", &A);
	test = scanf("%ld", &B);
	test = scanf("%ld", &H);
	test = scanf("%ld", &M);

	angH = H * 30;
	angM = M * 6;

	sa = angH - angM;
	//if (sa < 0) {
	//	sa *= -1;
	//}
	//if (sa > 180) {
	//	sa -= 180;
	//}

	//printf("%d\n", angH);
	//printf("%d\n", angM);
	//printf("%lf\n", sa);
	sa = sa* (pai / 180);
	//printf("%lf\n", sa);
	as = A;
	bs = B;
	A = A * A;
	B = B * B;
	kai = sqrt(A + B - 2*as*bs*cos(sa));
	printf("%lf", kai);
	return 0;
}