#include <stdio.h>
#include <math.h>
int main(){
	int A, B, H, M;
	scanf("%d %d %d %d", &A, &B, &H, &M);	
	long double h = M_PI * (H + M / 60.0) / 6.0, m = M_PI * M / 30.0;
	printf("%.10Lf\n", sqrtl((long double)A * A + (long double)B * B - 2.0 * A * B * cosl(h - m)));
	fflush(stdout);
	return 0;
}