process.stdin.resume();
process.stdin.setEncoding('utf8');
var lines = [];
var reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout,
    terminal: false
});
reader.on('line', (line) => {
    lines.push(line);
});
reader.on('close', () => {
    const [A, B, H, M] = lines[0].split(" ").map(e => parseFloat(e));
    const degB = M * 6.0;
    const degA = H * 30.0 + 30.0 * M / 60;
    const deg1 = Math.abs(degA - degB);
    const deg = deg1 > 180 ? 360 - deg1 : deg1;
    const rad = deg * Math.PI / 180;
    const ans = Math.sqrt(Math.pow(A,2) + Math.pow(B,2) - 2 * A * B * Math.cos(rad));
    console.log(ans);
});