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

#define PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067

int main()
{
	int a, b, h, m;
	double lx, ly, sx, sy;
	double lk, sk;
	double d;
	double s, c;

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

	lk = (h*60.0 + m) * 0.5;
	lk = lk * (double)(PI / 180.0);

	lx = a * cos(lk);
	ly = a * sin(lk);

	sk = m * 6.0;
	sk = sk * (double)(PI / 180.0);

	sx = b * cos(sk);
	sy = b * sin(sk);

	lx =lx - sx;
	ly =ly - sy;

	d = pow(lx, 2.0) + pow(ly, 2.0);

	d = sqrt(d);

	printf("%1.15lf\n", d);

	return 0;
}