"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const A = parseInt(arg[0].split(" ")[0]);
    const B = parseInt(arg[0].split(" ")[1]);
    const H = parseInt(arg[0].split(" ")[2]);
    const M = parseInt(arg[0].split(" ")[3]);
    
    let angleA = (360 / 12) * (H % 12);
    const angleB = (360 / 60) * M;
    angleA += 30 * (M / 60);
    
    const absAB = Math.abs(angleA - angleB);
    const angle = Math.min(absAB, 360 - absAB);
    
    let answer;
    
    answer = (Math.pow(A, 2) + Math.pow(B, 2)) - (2 * A * B) * (Math.cos(angle * (Math.PI / 180)));
    
    //console.log(angle);
    console.log(Math.sqrt(answer));
    // console.log(Math.cos(90))
    //console.log(Math.sqrt(20));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));