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

int main(void){
  double a, b;
  double h, m;
  double th_a, th_b;
  double deg;
  
  scanf("%lf %lf %lf %lf",&a, &b, &h, &m);
  
  th_a = 2.0 * M_PI * (h / 12.0);
  th_a = th_a + ((M_PI * m) / 360.0);
  th_b = 2.0 * M_PI * (m / 60.0);
  
  if(th_a > th_b){
 	 deg = a * a + b * b - 2.0 * a * b * cos(th_a - th_b);
  }else{
    deg =  a * a + b * b - 2.0 * a * b * cos(th_b - th_a);
  }
  
  printf("%.20f\n",sqrt(deg));
  return 0;
}