import math
a,b,h,m=map(int,input().split())
ha=h * 30 + (30 * (m / 60))
ma=360 * (m / 60)
angle=max(ha,ma)-min(ha,ma)
if angle>=180:
  angle-=180
if angle==90:
  print(math.sqrt(a*a+b*b))
elif angle==0 or angle==180:
  if angle==0:
    print(abs(a-b))
  else:
    print(a+b)
else:
  angle=angle/180*math.pi
  #print(ha,ma,angle,math.cos(angle))
  ans=math.sqrt(a*a+b*b-2*a*b*math.cos(angle))
  print(ans)
