#include<stdio.h>
#include <stdlib.h>
#include<math.h>
#define PI 3.141592653589793238
int main(){
   int A,B,H,M;
   scanf("%d %d %d %d",&A,&B,&H,&M);
   long double a,b,d,r,ans;
   a=30*H+M/2;
   b=6*M;
   d=labs(a-b);
   if(d>180){
   d=d-180;
   }
    r=d*(PI/180);
    ans=sqrt(B*B+A*A-2*A*B*cos(r));
    printf("%.20lf",ans);
 
   return 0;
}
