#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(){
    int a,b,h,m;
    scanf("%d%d%d%d",&a,&b,&h,&m);
    const double pi=3.14159265359;
    const double wh=(2*pi)/(12*3600);
    const double wm=(2*pi)/(3600);
    double x,y;
    int sec;
    x=60*60*h*wh;
    y=60*m*wm;
    /*while(x>(2*pi)){
        x=x-2*pi;
    }
    while(y>(2*pi)){
        y=y-2*pi;
    }*/
    double z;
    z=x-y;
    /*if(z>pi)
    z=2*pi-z;*/
    double ans;
    ans=a*a+b*b+2*a*b*cos(z);
    ans=sqrt(ans);
    printf("%lf",ans);
}
