/*  ex4_2
    B30095    */
#include <stdio.h>
#include <math.h>
#define PI 3.14159265359
 
int main(void){
    int hourHndLen, mntHndLen, hour, minute;
    scanf("%d %d %d %d", &hourHndLen, &mntHndLen, &hour, &minute);

    double hourAngle = hour * 30 + minute * 0.5;  // angle between hour hand and 12 'O clock
    double mntAngle = minute * 6;                 // angle between minute hand and 12 'O clock
    double angleDiffRad = fabs((hourAngle - mntAngle) * PI / 180);  // angle between hands in radian
    double distance = sqrt(hourHndLen * hourHndLen + mntHndLen * mntHndLen - 2 * hourHndLen * mntHndLen * cos(angleDiffRad));

    printf("%.9f", distance);
    return 0;
}