import java.util.Scanner
import Math._

object Main {
  def main(args: Array[String]): Unit = {

    val sc = new Scanner(System.in)
    val a = sc.nextDouble()
    val b = sc.nextDouble()
    val h = sc.nextDouble()
    val m = sc.nextDouble()

    val needleM = 360D * m / 60D
    val needleH = 360D * (h * 60 + m) / (12D * 60D)


    val angC = abs(needleH - needleM) match {
      case x if x > 180D => 360D - x
      case x => x
    }

    val c = sqrt(pow(a, 2D) + pow(b, 2D) - (2D * a * b) * cos(Math.toRadians(angC)))

    println(c)
  }

}
