function Main(args){
    const input = args.trim().split(" ");
    const [A, B, H, M] = input;

    const c = (H / 12 + M / (12*60) - M / 60) * Math.PI * 2;
    const ans = (A**2 + B**2 - 2*A*B*Math.cos(c)) ** 0.5;
    console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));