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

int main(){

    int A, B, H, M;
    scanf("%d%d%d%d", &A, &B, &H, &M);
    
    double pi = M_PI; // %.9f

    double thetaB = (2.0*pi*M)/60.0;
    double thetaA = (H*pi)/6.0 + (pi*M)/(6.0*60.0);
    //double thetaB = 6.0*M;
    //double thetaA = 30.0*H + M*0.50;
    //printf("%f %f\n", thetaA, thetaB);

    double theta = fabs( thetaA - thetaB );
    if( theta > pi ){
        theta = 2*pi - theta;
    }
    /*
    if( theta > 180.0 ){
        theta = 360.0 - theta;
    }
    */
    //printf("%lf\n", theta);

    //theta = (theta*pi)/180.0;

    double ans;
    ans = A*A + B*B - 2.0*A*B*cos(theta);

    printf("%.9lf\n", sqrt(ans));

    return 0;
}
