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


int main(void){

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

    ACB = fabsl(2*M_PI*H/12+2*M_PI/12/60*M-2*M_PI*M/60);

    if(ACB>=M_PI){
        ACB = 2*M_PI - ACB;
    }

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

    printf("%Lf", ans);

    return 0;
}