#include<stdio.h>
#include <stdlib.h>
#include<math.h>
#define PI 3.1415926535897932384626
int main(){
   int A,B,H,M;
   scanf("%d",&A);
   scanf("%d",&B);
   scanf("%d",&H);
   scanf("%d",&M);
   double a,b,d,r,ans;
   a=360*A/12+30*B/60;
   b=360*B/60;
   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("%f",ans);
   return 0;
}
