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

int main(void){
    int A,B,H,M;
    double a,b,h,m,x,j,s;
    scanf("%d %d %d %d",&A,&B,&H,&M);
    a=A;
    b=B;
    h=H%12;
    m=M;

    s=(60*h-11*m)/360*3.1415926536535;
    j=a*a+b*b-2*a*b*cos(s);
    x=sqrt(j);

    printf("%.50Lf",x);


    return 0;
}