import math
A,B,H,M = map(float,input().split())
vec = 0
c = abs((30.0*H + M*0.5) - (M*6.0))
if c <= 180.0:
    vec = c
else:
    vec = 360.0 - c
ans = math.sqrt(A**2 + B**2 - 2.0*A*B*math.cos(vec))
print(ans)