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

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

    s=(60.0L*h-11.0L*m)/360.0L*3.14159265358979L;
    j=a*a+b*b-2.0L*a*b*cosl(s);
    x=sqrtl(j);
    answer =x;
    printf("%.50Lf",answer);
    return 0;
}