#include <stdio.h>
#include <math.h>
#define PI 3.1415926535L

int main(){
	int a, b, h, m;
	long double csq, cosab;
	scanf("%d %d %d %d\n", &a, &b, &h, &m);
	csq = a*a + b*b -2.0L*a*b*(cosl((2.0L*PI*(h+m/60.0L)/12.0L)-(2.0L*PI*m/60.0L)));
	printf("%.16Lf\n", sqrtl(csq));
	return 0;
}
