/*  ex4_2
    supercomputerjoi    */

#include <stdio.h>
#include <math.h>

int main(void){

    int shortHand, longHand, hour, minute;
    double theta;  // angle between long hand and short hand
    double ans;    // answer

    // input A B H M
    scanf("%d %d %d %d", &shortHand, &longHand, &hour, &minute);

    // calculate angle
    theta = 2 * M_PI * (hour / 12.0 + minute / 720.0 - minute / 60.0);

    // calculate answer by cosine formula
    ans = sqrt(pow(shortHand, 2) + pow(longHand, 2) - 2 * shortHand * longHand * cos(theta));

    // print answer
    printf("%.9f\n", ans);

    return 0;
}