#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
typedef long long ll;
typedef long double ld;
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))

int main() {
	ld a, b, h, m, the, l;
	scanf("%lf %lf %lf %lf",&a,&b,&h,&m);
	the = Ma((3.1415926535897932 / 180) * (30 * h - 5.5 * m), (3.1415926535897932 / 180) * (5.5 * m - 30 * h));
	l = sqrtl(a * a + b * b - 2 * a * b * cosl(the));
	printf("%.11lf", l);
}