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

int main(void) {
	int a, b, h, m;
	double ccc, c, angle;

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

	angle = (h * 30 - m) * 3.141592 / 180;
	ccc = fabs(cos(angle));

	c = sqrt(a * a + b * b - 2 * a * b * ccc);

	printf("%d", c);

	return 0;
}
