import math

a,b,h,m=map(int,input().split())

aa=a*a
bb=b*b


mm=m*6

hh=h*30+30*m/60
if hh-mm<=180:
    cos = math.cos(math.radians(abs(hh-mm)))
else:
    cos = math.cos(math.radians(abs(360-(mm-hh))))
#print(cos)
cc=aa+bb-2*a*b*cos

c=math.sqrt(cc)

print(c)

