import math
a,b,h,m=map(int,input().split())
h=h*30+m*0.5
m=m*6
ma=max(h,m)
mi=min(h,m)
kakudo=abs(ma-mi)
if kakudo>180:
    kakudo-=180
elif kakudo ==0:
    print(abs(a-b))
    exit()
elif kakudo==180:
    print(a+b)
    exit()
#print(kakudo)
c=math.cos(math.radians(kakudo))
ans=a**2+b**2-2*a*b*c
ans=ans**0.5
print(ans)