import math
A, B, H, M = map(int, input().split())

PI = math.pi
radA = (2.0 * PI * (H + M / 60.0)) / 12.0
radB = (2.0 * PI * M) / 60.0
#print(math.hypot(A * math.cos(radA) - B * math.cos(radB),
#                 A * math.sin(radA) - B * math.sin(radB)))
print(math.sqrt(A**2 + B**2 - 2*A*B*math.cos(radA-radB)*math.sin(radA-radB)))