const input = require("fs").readFileSync("/dev/stdin", "utf8")
const lines = input.split('\n')
const [A, B, H, M] = lines[0].split(' ').map(Number)

const radH = (H * 30 + M / 2) * ( Math.PI / 180 )
const radM = M * 6 * ( Math.PI / 180 )

const posHX = Math.cos(radH) * A
const posHY = Math.sin(radH) * A

const posMX = Math.cos(radM) * B
const posMY = Math.sin(radM) * B

const dist = Math.sqrt(Math.pow(posHX - posMX, 2) + Math.pow(posHY - posMY, 2))
console.log(dist)