/* ex4_2
   kohei_suzuki */

#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>

int main(void){
    double short_hand, long_hand, hour, min;
    double angle, ans;

    scanf("%lf %lf %lf %lf",&short_hand, &long_hand, &hour, &min);
    angle = fabs(hour*30.0 + min/2.0 - min*6.0) / 180.0 * M_PI;

    ans = sqrt(pow(short_hand ,2.0)+ pow(long_hand, 2.0) - 2 * short_hand * long_hand * cos(angle));

    printf("%.9f\n",ans);
    return 0;
}