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

int main(void){
    int H, M, A, B; 
    double Hx, Hy, Mx, My, Hr, Mr;
    double d;

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

    Hr = (M_PI/2) - (M_PI/6)*H - (M_PI/360)*M;
    Hx = A*cos(Hr);
    Hy = A*sin(Hr);
    Mr = (M_PI/2) - (M_PI/30)*M;
    Mx = B*cos(Mr);
    My = B*sin(Mr);

    d = sqrt((Hx - Mx)*(Hx - Mx) + (Hy - My)*(Hy - My)); 
    printf("%f\n", d);

    return 0;
}
