a,b,h,m = map(int,input().split())
import math
alp = 0.5*(h*60+m)/180*math.pi
be = 6*m/180*math.pi
if alp >=be:
    if alp-be < math.pi: 
        l = (a**2+b**2 - 2*a*b*math.cos(alp - be))**(1/2)
    else:
        l = (a**2+b**2 + 2*a*b*math.cos(alp - be))**(1/2)
else:
    if be-alp < math.pi:
        l = (a**2+b**2 - 2*a*b*math.cos(be - alp))**(1/2)
    else:
        l = (a**2+b**2 + 2*a*b*math.cos(be - alp))**(1/2)
print(l)