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);

    hAngle = (30 * hours) + (0.5 * minuts);

    if (hAngle == 90) {
        hoursX = hHand;
        hoursY = 0;
    } else if(hAngle == 180){
        hoursX = 0;
        hoursY = -hHand;
    }else if(hAngle == 270){
        hoursX = -hHand;
        hoursY = 0;
    } else{
        hoursX = hHand * Math.sin(hAngle*(Math.PI/180));
        hoursY = hHand * Math.cos(hAngle*(Math.PI/180));
    }

    mAngle = (6 * minuts);


    if (mAngle == 90) {
        minutsX = mHand;
        minutsY = 0;
    } else if(mAngle == 180){
        minutsX = 0;
        minutsY = -mHand;
    }else if(mAngle == 270){
        minutsX = -mHand;
        minutsY = 0;
    } else{
        minutsX = mHand * Math.sin(mAngle*(Math.PI/180));
        minutsY = mHand * Math.cos(mAngle*(Math.PI/180));
    }

    distance = Math.hypot(hoursX - minutsX, hoursY - minutsY);
    console.log(distance);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));