#include<stdio.h>
#include<math.h>
#define pai 3.14159265
int main(){
    int a,b,h,m;
    scanf("%d %d %d %d",&a,&b,&h,&m);
    double dgreeh=30.0*h+m/2;
    double dgreem=6.0*m;
    double dgree;
    //printf("dgreeh %f\ndgreem %f\n",dgreeh,dgreem);
    if(dgreeh>dgreem){
        dgree=dgreeh-dgreem;  
    }else{
        dgree=dgreem-dgreeh;
    }
    if(dgree>180){
      dgree=360-dgree;
    }
    //printf("dgree %d\n",dgree);
    double rad=dgree*(pai/180);
    double result=a*a+b*b-2*a*b*cos(rad);
   // printf("a %d\nb %d\ncos %f\nresult %f\n",a,b,cos(rad),result);
    result=sqrt(result);
    printf("%f\n",result);
    return 0;
}