'use strict';

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

    const h = H * 30 + M * 0.5;
    const m = M * 6;

    const t = (Math.max(h,m) - Math.min(h,m));
    const c = t > 180 ? t - 180 : t;

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

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