local PI, sin, cos, sqrt = math.pi, math.sin, math.cos, math.sqrt

local A, B, H, M = io.read("*n", "*n", "*n", "*n")

local A_rad = 2 * PI * ((H + M / 60) / 12)
local B_rad = 2 * PI * (M / 60)

local x_len = A * cos(A_rad) - B * cos(B_rad)
local y_len = A * sin(A_rad) - B * sin(B_rad)

print(sqrt(x_len^2 + y_len^2))