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

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

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

	sa = abs(angH - angM);
	//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);
	kai = sqrt(A*A*1.0 + B*B*1.0 - 2.0*A*B*cos(sa));
	printf("%lf", kai);

}