"use strict";
// 2254
const main = arg => {
    const input = arg.trim().split("\n");

    const a = parseInt(input[0].split(" ")[0]);
    const b = parseInt(input[0].split(" ")[1]);
    const h = parseInt(input[0].split(" ")[2]);
    const m = parseInt(input[0].split(" ")[3]);
    let angS = 360*m/60
    let angL = 360*5*h/60 + 360/12*m/60
    const diff = angS > angL ? angS-angL : angL-angS
    const rad = diff*Math.PI/180
    let x = Math.sqrt(a*a + b*b - 2*a*b*Math.cos(rad))
    console.log(x)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));  
