#include <stdio.h>
#include <math.h>
int main(void){
    int A,B,H,M,time;
    double a,b,kaku,C,M_PI=3.14159265359;
    
    scanf("%d",&A);
    scanf("%d",&B);
    scanf("%d",&H);
    scanf("%d",&M);
    
    time=H*60+M;
    
    a=(double)time/2.0;
    b=6.0*M;
    
    kaku=a-b;
    if(kaku>180){
        kaku=kaku-180;
    }else if(kaku<0){
        kaku=kaku*(-1);
    }
    
    C=sqrt(A*A+B*B-2*A*B*cos(kaku*M_PI/180.0));
    
    printf("%.20f\n",C);
    
    return 0;
}