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


int a,b,h,m;

int main(){
  scanf("%d%d%d%d",&a,&b,&h,&m);
 
  double rad1 = 1.0*2*M_PI*(1.0*h/12+1.0/60/12*m);
  double rad2 =  1.0*2*M_PI*m/60;
  double rad = rad1-rad2;
  /*
  if(rad1>rad2){
    rad = rad1-rad2;}
  else{
    rad = rad2-rad1;}
  */
  double ans = sqrt(1.0*a*a+1.0*b*b-2.0*a*b*cos(rad));

  printf("%lf\n",ans);
  
  return 0;
}
