#include <stdio.h>
#include <math.h>
#define PI 3.14159265
int main(void){
    int lenA,lenB,hour,min;
    double angleA,angleB,angleA_B,lenA_B;
    scanf("%d %d %d %d",&lenA,&lenB,&hour,&min);
    angleA=(2*PI/12)*hour+(2*PI/720)*min;
    angleB=(2*PI/60)*min;
    angleA_B=((angleA-angleB)>0)?(angleA-angleB):(angleB-angleA);
    lenA_B=sqrt(lenA*lenA+lenB*lenB-2*lenA*lenB*cos(angleA_B));
    printf("%.9lf\n",lenA_B);
    return 0;
}