#include <bits/stdc++.h>
int main() {
  double a, b, h, m, x, y;
  scanf("%lf %lf %lf %lf", &a, &b, &h, &m);
  double t = fabs((h + m / 60.0) / 12.0 - m / 60.0) * 2 * M_PI;
  if (t == 0) {
    printf("%.11f\n", (fabs(a - b)));
    return 0;
  }
  if (t == M_PI) {
    printf("%.11f\n", (fabs(a + b)));
    return 0;
  }
  double d;
  if (t < M_PI / 2 || M_PI * 3 / 2 < t) {
    x = (a - b * cos(t));
    y = (b * sin(t));
  } else {
    x = (a + b * cos(t));
    y = (b * sin(t));
  }
  d = sqrt(x * x + y * y);
  printf("%.17f\n", d);
  return 0;
}
