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

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) < (b) ? (a) : (b))

int main(void) {
	int A, B, H, M;
	
	scanf("%d %d %d %d", &A, &B, &H, &M);
	
	double rad_A = M_PI * 2.0 * H / 12 + M_PI * 2.0 * M / 12 / 60;
	double rad_B = M_PI * 2.0 * M / 60;
	
	double distance = sqrt(A * A + B * B - 2 * A * B * cos(max(rad_A, rad_B) - min(rad_A, rad_B)));
	
	printf("%.16f\n", distance);
	
	return 0;
}