input_ints :: IO [Int]
input_ints = do
    a <- getLine
    return (map read (words a))

from_ints :: (Num a) => [Int] -> [a]
from_ints ns = map fromIntegral ns

hour_angle :: Int -> Int -> Double
hour_angle hour minute = (hour' * angle_per_hour) + (minute' * (angle_per_hour/60))
    where 
        angle_per_hour = 2*pi/12
        [hour', minute'] = from_ints [hour, minute]

minute_angle :: Int -> Double
minute_angle minute = minute' * (2*pi/60)
    where minute' = fromIntegral minute

edges_distance :: Int -> Int -> Int -> Int -> Double
edges_distance h_length m_length hour minute =
    let h_angle = hour_angle hour minute
        m_angle = minute_angle minute
        interior_angle = abs (h_angle - m_angle)
        [h_length', m_length'] = from_ints [h_length, m_length]
        distance = sqrt(h_length'^2 + m_length'^2 - (2 * h_length' * m_length' * (cos interior_angle)))
    in distance

main = do
    [h_length ,m_length ,hour ,minute] <- input_ints
    let distance = edges_distance h_length m_length hour minute
    putStrLn (show distance)
