import kotlin.math.*
fun main(args: Array<String>) {
  val n = readLine()!!.split(' ').map(String::toDouble)
  var angle = 0.0
  if(Math.abs(n[2]*PI/6.0 - n[3]*11*PI/360.0) > PI){
    angle = 2.0*PI - Math.abs(n[2]*PI/6.0 - n[3]*11*PI/360.0)
  }else{
    angle = Math.abs(n[2]*PI/6.0 - n[3]*11*PI/360.0)
  }
  println(Math.sqrt(n[0]*n[0] + n[1]*n[1] - 2*n[0]*n[1]*cos(angle)))
  //val s = cos(PI)
  //println(s)
}