const main = (args) => {
    const input = args.trim().split(' ');
    const A = input[0];
    const B = input[1];
    const H = input[2];
    const M = input[3];

    const c = (H / 12.0 + M / (12.0 * 60.0) - M / 60.0) * Math.PI * 2;
 
    const ans = Math.sqrt(Math.pow(A,2) + Math.pow(B,2) - (2 * A * B) * Math.cos(c));
    console.log(ans);

}
main(require('fs').readFileSync('/dev/stdin', 'utf-8'));