#include <stdio.h>
#include <stdlib.h>
#include <math.h>
typedef long double ld;

int main() {
	ld a, b, h, m, the, l;
	scanf("%lf %lf %lf %lf",&a,&b,&h,&m);
	m += 60 * h;
	the = (3.141592653589793238462643383279502884 * 11 * m) / 360;
	l = sqrtl(a * a + b * b - 2 * a * b * cosl(the));
	printf("%.16lf", l);
}