#include <stdio.h>
#include<math.h>
long double M_PI=3.1415926535;
long double radian(int H,int M){
    long double t;
    t=fabs(30.*H-5.5*M);
    //printf("%20.20Lf",t);
    return t;
}
int main(void){
    // Your code here!
    int A,B,H,M;
    long double t;
    scanf("%d",&A);scanf("%d",&B);scanf("%d",&H);scanf("%d",&M);
    t=radian(H,M);
    long double d=sqrt((long double)(A*A+B*B-2*A*B*cos(M_PI*t/180.)));
    printf("%20.20Lf",d);
    return 0;
}