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 diffHM = m === 0 ? 0 : (m / 60) * 30;
    m = m - h * 5;
    m = m < 0 ? m + 60 : m;
    h = 0;
    m = m - diffHM / 6;
 
    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 = (60 - m) * 6
    } else {
        console.log('error');
        return;
    }
 
    var rad = deg * (Math.PI / 180);
    var result = (a * a) + (b * b) - (2 * a * b * Math.cos(rad));
    console.log(Math.sqrt(result));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));