main :: IO ()
main = do
  l1 <- getLine
  let [a, b, h, m] = map (fromIntegral . read) $ words l1 :: [Double]
      w1 = (60*h + m)/(12*60) * 2*pi
      w2 = m/60 * 2*pi
      p1 = (a*sin w1, a*cos w1)
      p2 = (b*sin w2, b*cos w2)
  print $ d p1 p2

d (x1, y1) (x2, y2) = sqrt $ (x2 - x1)**2 + (y2 - y1)**2
