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

int main(void){
    int a,b,h,m;
    scanf("%d%d%d%d",&a,&b,&h,&m);
    long double hm = 30.0l * h + m / 2.0l;
    long double mm = m * 6.0l;
    long double ans;
    long double diff;
    if(hm-mm > 180.0l)diff = hm - mm + 360.0l;
    else diff = hm - mm;
    long double d =  diff/ 180.0l * M_PI;
    if(a > b) ans = sqrtl((cosl(d)*a - b)*(cosl(d)*a - b) + (a*sinl(d))*(a*sinl(d)));
    else ans = sqrtl((cosl(d)*b - a)*(cosl(d)*b - a) + (b*sinl(d))*(b*sinl(d)));
    printf("%.10Lf",ans);
}