import math

a, b, h, m = map(int, input().split())
colon = float()

h_angle = 30 * h
m_angle = 6 * m

angle = abs(h_angle - m_angle)

if angle >= 180:
    angle -= 180


colon = a ** 2 +  b ** 2  - 2 * a * b * (math.cos(math.radians(angle)))

print(math.sqrt(colon))