"use strict";
function main(input) {
    var line = input.split(" ");
    let a = parseInt(line[0]);
    let b = parseInt(line[1]);
    let h = parseInt(line[2]);
    let m = parseInt(line[3]);
    
    var angle = 0.5*(60*h - 11*m);
    if(angle>180) angle = angle-360;
    //convert into degree
    angle = (angle*3.14159265359)/180;
    var cost = Math.cos(angle);
    var sqs = (a*a)+(b*b) - (2*a*b*(cost));
    var ans = Math.sqrt(sqs);
    console.log(ans.toPrecision(20));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
