import math
import sys
import numpy as np
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=360-kakudo
elif kakudo == 0:
    print(abs(a-b))
    exit()
elif kakudo==180:
    print(a+b)
    exit()
c=math.cos(math.radians(kakudo))
#print(c)
ans=math.pow(a,2)+math.pow(b,2)-2*a*b*c
ans=math.sqrt(ans)
print(ans)