function Main(input) {
    tmp = input.split(" ");
    hHand = parseInt(tmp[0], 10);
    mHand = parseInt(tmp[1], 10);
    hours = parseInt(tmp[2], 10);
    minuts = parseInt(tmp[3], 10);

    mAngle = (360 / 60) * minuts;
    if (mAngle == 360) {
        mAngle = 0;
    }

    minutsX = mHand * Math.cos(mAngle*(Math.PI/180));
    minutsY = mHand * Math.sin(mAngle*(Math.PI/180));


    hAngle = (360 / 12) * hours;

    if (hAngle == 360) {
        hAngle = 0;
    }

    hoursX = hHand * Math.cos(hAngle*(Math.PI/180));
    hoursY = hHand * Math.sin(hAngle*(Math.PI/180));

    distance = Math.hypot(hoursX - minutsX, hoursY - minutsY);
    console.log(distance);


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