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


int main(){
    double A,B,H,M;
    scanf("%lf %lf %lf %lf",&A,&B,&H,&M);

    double ax,ay,bx,by,pi,dis;
    pi =  atan(1.0) * 4.0;

    ax = A*sin((H/6+M/360)*pi);
    ay = sqrt(A*A-ax*ax);
    if(H>=3&&H<9)ay = -ay;
    
    bx = B*sin((M/30)*pi);
    by = sqrt(B*B-bx*bx);
    if(M>=15&&M<45)by =-by;

    dis = sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by));

    printf("%.16f\n",dis);
    
    return 0;
}