import java.util.Scanner
import math._

object Main extends App {
  val sc = new Scanner(System.in)
  val A, B, H, M = sc.nextDouble

  val c = cos(abs(((H*60 + M) / (12*60) - M / 60) * 2 * Pi))
  val z = sqrt(A * A + B * B - 2 * A * B * c)
  println(f"$z%.20f")
}
