import scala.io.StdIn._
object Main extends App {
  val read = readLine().split(' ').map(_.toInt)
  val alpha = math.Pi * read(3) * 6 / 180
  val beta = (math.Pi * (read(2) * 30 + read(3) * 0.5)) / 180
  val Ax = read(0) * math.cos(alpha)
  val Ay = read(0) * math.sin(alpha)
  val Bx = read(1) * math.cos(beta)
  val By = read(1) * math.sin(beta)
  val cos = (Ax * Bx + Ay * By) / (read(0) * read(1))
  val AB2 = read(0) * read(0) + read(1) * read(1) - 2 * read(0) * read(1) * cos
  val AB = math.sqrt(AB2)
  println(AB)
}
