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

int main(void) {
  int a, b, h, m;
  scanf("%d%d%d%d", &a, &b, &h, &m);
  double degree = 0;
  if(h / 12.0 > m / 60) {
    degree += h * 30 + m * 0.5;
    degree -= m * 6;
  } else {
    degree += m * 6;
    degree -= (h * 30 + m * 0.5);
  }
  if(degree > 180) degree = 360 - degree;
  printf("%f\n", sqrt(a * a + b * b - 2 * a * b * cos(degree * 3.141592 / 180.0)));
  return 0;
}
  