import math
A,B,H,M = map(float, input().split())
rate = M / 60.0
HM = H*5.0 + 10.0*rate
theta = abs(HM-M) * 6.0
if theta > 180:
    theta = 360-theta
#rad = math.radians(theta)
#cos = abs(math.cos(rad))
L = math.sqrt(A**2 + B**2 - 2*A*B*abs(math.cos(math.radians(theta))))
if H==0 and M ==0:
    L = 0
print("{:.19f}".format(L))