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

int main (void){
    int A,B;
    int H,M;
    double alpha,beta;
    double ans,ansre;

    scanf("%d %d %d %d",&A,&B,&H,&M);

    alpha=H*M_PI/6+M*M_PI/360;
    beta=M*M_PI/30;

    ans = hypot(A*cos(-alpha+M_PI/2)-B*cos(-beta+M_PI/2),A*sin(-alpha+M_PI/2)-B*sin(-beta+M_PI/2));


    ansre=A*A+B*B-2.0*A*B*cos(alpha-beta);
    ansre=sqrt(ansre);
    
    //printf("%f\n",ansre);
    printf("%f",ans);


    return 0;
}