/* ex4_2
   Acro  */

#include <stdio.h> 
#include <math.h>
#include <stdlib.h>
int main(void){
    int length_h,length_m,hour,minute;
    long double ans,theta;
    scanf("%d %d %d %d",&length_h,&length_m,&hour,&minute);
    /* 角度を求める */
    theta = 2*M_PI * ((minute/(long double)60) - (hour/(long double)12 + minute/(long double)(12*60)));
    /* 余弦定理 */
    ans = sqrt((long double)length_h*length_h + (long double)length_m*length_m - (long double)2*length_h*length_m*cos(theta));
    printf("%20.20Lf\n",ans);
    return 0;
}