import math

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

hangle = float((h/12)*360)
hangle += float((m/60)*30)
mangle = float((m/60)*360)

if hangle > 180 and mangle > 180:
    angle = abs(hangle-mangle)
elif hangle > 180:
    hangle = 360-hangle
    angle = abs(hangle-mangle)
elif mangle > 180:
    mangle = 360-mangle
    angle = abs(hangle-mangle)
else:
    angle = abs(hangle-mangle)

if hangle > 180:
    hangle = 360-hangle
if mangle > 180:
    mangle = 360-mangle

angle = abs(hangle-mangle)
rad = math.radians(angle)

ans = float(math.sqrt(a*a + b*b - float(2*a*b*math.cos(rad))))

if m != 0 and h != 0:
    print('{:.10f}'.format(ans))
else :
    print(0)