const input = require("fs").readFileSync("/dev/stdin", "utf8")
let cin = input.split(/ |\n/), cid = 0
const next = () => cin[cid++]
const nexts = (n) => cin.slice(cid, cid+=n).map(i=>parseInt(i))

const [A, B, H, M] = nexts(4)

const long = M * 6.0
const short = (H + M / 60) * 30.0
let angle = Math.abs(long - short)

if (angle % 180 == 0) {
    console.log(0)
    retrun
}

if (angle > 180) angle -= 180

// console.log(long, short, angle)
const result = Math.sqrt(A**2 + B**2 - 2 * 3 * 4 * Math.cos(angle * (Math.PI / 180)))
console.log(result)
