import math

A,B,H,M = map(int,input().split())
MM = 6*M #分針の角度
HH = H*30 + M//2
rad = MM-HH
if(rad>=-90 and rad<=90):
    cosine = math.cos(math.radians(rad))
else:
    cosine = 0-math.cos(math.radians(rad))
    
r = math.sqrt(A**2+B**2-2*A*B*cosine)
print(r)