function main(input) {
    var args = input
        .trim()
        .split(' ');
    var a = args[0];
    var b = args[1];
    var h = args[2];
    var m = args[3];

    var diff = 0
    while (h !== 0) {
        --h;
        ++diff;
    }
    m = m - diff * 5;
    m = m < 0 ? m + 60 : m;
    m = m > 30 ? 60 - m : m;

    var deg = 0;
    if (m === 0) {
        console.log(0);
        return;
    } else if (m === 30) {
        console.log(a + b);
        return;
    } else if (m < 30) {
        deg = m * 6;
    } else if (m > 30) {
        deg = (m - 30) * 6
    } else {
        console.log('error');
        return;
    }
    var rad = deg * (Math.PI / 180);
    var result = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(rad);
    console.log(Math.sqrt(result));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
