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

int main (void){
    int a,b,h,m;
    double angle,h_ang,m_ang;
    double ans;
    scanf("%d %d %d %d",&a,&b,&h,&m);
    h_ang = 2.0*M_PI*h/12.0 + 30.0/360.0*2.0*M_PI*m/60.0;
    m_ang = 2.0*M_PI*m/60.0;
    angle = fabs(h_ang-m_ang);
    if(angle > M_PI) angle = 2*M_PI - angle;
    ans = sqrt(a*a + b*b - 2*a*b*cos(angle));
    printf("%.10f",ans);
    return 0;
}