#include <stdio.h>
#include <math.h>
#define PI 3.14159265

int main(void){
    int A,B,H,M;
    double ans;
    
    scanf("%d%d%d%d",&A,&B,&H,&M);
    
    ans = cos(2*PI*(H/12.0 + (M/(60.0*12.0)) - M/60.0));
    printf("%lf\n",sqrt(A*A+B*B-2*A*B*ans));
    
}