main = getLine >>= print . solve . map read . words

solve (a:b:h:m:_) = sqrt ((xa - xb)^2 + (ya - yb)^2)
  where da = 2 * pi * (60 * h + m) / (60 * 12)
        xa = a * cos(da)
        ya = a * sin(da)
        db = 2 * pi * m / 60
        xb = b * cos(db)
        yb = b * sin(db)