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

int main(void) {
  int a, b, h, m;
  int deg;

  scanf("%d %d %d %d", &a, &b, &h, &m);
  deg = 6 * m - (30 * h + 0.5 * m);
  if (deg < 0) {
    deg = -deg;
  }
  if (deg >= 360) {
    deg = deg % 360;
  }

  printf ("%.10f\n", sqrt(a*a + b*b - 2*a*b*cos(deg * 2 * M_PI / 360)));
  return 0;
}