import math
A, B, H, M = [int(i) for i in input().split()]
h = H* 2*math.pi/12 #rad
m = M* 2*math.pi/60 #rad
#print(h, "\n", m)
def kyori(a,b,c,d):
    return math.sqrt(a**2+b**2-2*a*b*math.cos(c-d))

print(kyori(A,B,h,m))