import math
a,b,h,m = map(int, input().split())
if h > 12:
    h_c = h-12
else:
    h_c = h
p_d = 6*(abs((h_c)*5 - m))
if p_d >= 180:
    p_d2 = 360 - p_d 
    d_2 = a**2 + b**2 - 2*a*b*math.cos(math.radians(p_d2))
    print(math.sqrt(d_2))
else:
    d_2 = a**2 + b**2 - 2*a*b*math.cos(math.radians(p_d))
    print(math.sqrt(d_2))