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


int main(void){

    int A,B,H,M;
    double ACB,ans;
    scanf("%d %d %d %d", &A, &B, &H, &M);

    ACB = fabs(M_PI/30*(5*H-M));

    if(ACB>=180){
        ACB = 360 - ACB;
    }

    ans = sqrt(A*A+B*B-2*A*B*cos(ACB));

    printf("%f", ans);

    return 0;
}