#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 = fabsl(M_PI/360*(60*H-11*M));

    if(ACB>=M_PI){
        ACB = 2*M_PI - ACB;
    }
 
    ans = sqrt(A*A+B*B-2*A*B*cos(ACB));

    printf("%f", ans);

    return 0;
}