function main(lines) {
    const input = lines.split(' ').map(Number)
    const A = input[0]
    const B = input[1]
    const H = input[2]
    const C = input[3]
    
    const theta = (360) * H/12 + 0.5*C - (360) * C/60
    const output = Math.sqrt( A*A + B*B - 2*A*B*Math.cos(theta * Math.PI/180) )
    console.log(output.toFixed(9))
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
