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

#define PI 3.141592653589793238

int main() {
    
    int A,B,H,M;
    double deg_H,deg_M,deg,ans;
    
    scanf("%d %d %d %d",&A,&B,&H,&M);
    
    deg_H = PI * H / 6 + PI * M / 360;
    deg_M = PI * M / 30;
    deg = fabs(deg_H - deg_M);
    
    ans = sqrt(A * A + B * B - 2 * A * B * cos(deg));
    
    printf("%.9lf\n",ans);
    
    return 0;
}
