const main = input => {
const [a, b, c, d] = input.trim().split(" ").map(e => Number.parseInt(e))
const h = (360 / 12 / 60) * (Math.PI / 180);
const m = (360 / 60) * (Math.PI / 180);
const x1 = b*Math.cos(m*d) // m-x
const x2 = a*Math.cos(h*(c*60+d)) // h-x
const y1 = b*Math.sin(m*d) // m-y
const y2 = a*Math.sin(h*(c*60+d)) // h-y
return Math.sqrt((x1-x2)**2+(y1-y2)**2)
}
console.log(main(require('fs').readFileSync('/dev/stdin', 'utf8')))