#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <math.h>

int main(int argc, char *argv[]) {
	char line[128];
	int a, b, h, m;
	double l, s;

	fgets(line, 128, stdin);
	sscanf(line, "%d %d %d %d", &a, &b, &h, &m);

	l = m * 6;
	s = h * 30 + m * 0.5;

	s = (int)s % 360;
	l = fabs(s - l);

	if (l >= 180) l -= 180;
	printf("%0.20f\n", sqrt(pow(a, 2) + pow(b, 2) - 2 * (a * b * cos(l * M_PI / 180))));

    return EXIT_SUCCESS;
}

