#include <bits/stdc++.h>
int main() {
  int a, b, h, m, e;
  double answer, t, k, c, d;
  scanf("%d%d%d%d", &a, &b, &h, &m);
  c = 30.0 * h + m * 0.50;
  d = 6.0 * m;
  k = c - d;
  if (k < 0) {
    k = -k;
  }
  if (k > 180.0) {
    k = k - 180.0;
  }
  t = k * (3.1415926535897932384626433832795028841971693 / 180.0);
  answer = sqrt(a * a + b * b - 2.0 * a * b * cos(t));
  printf("%.10f", answer);
  return 0;
}
