
import math


I = input().split()
A = int(I[0])
#hour hand length cm
B = int(I[1])
#minute hand length cm
H = int(I[2])
#hours
M = int(I[3])
#key?
#mins

tha = 30*H 
thb = 6*M
diff= (math.pi/180)*(tha-thb)

#(theta, radius)
d = math.sqrt(A**2 + B**2 - 2*A*B*(math.cos((diff))))


print(d)
