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

int main()
{
  int a, b, h, m;
  double c;
  double pi = atan(1.0) * 4.0;
  
  scanf("%d%d%d%d", &a,&b,&h,&m);
  
  if(30 * h - 6 * m < 0){
    c = -pi / 180 * (30 * h - 6 * m);
  }else{
    c = pi / 180 * (30 * h - 6 * m);
  }
  
  if(c == pi){
    printf("%.10f\n", (double)a + b);
  }else{
    printf("%.10f\n", sqrt(a * a + b * b - 2 * a * b * cos(c)));
  }
  
  return 0;
}