#include <bits/stdc++.h>
int main() {
  double a, b, h, m, time;
  double kaku, len;
  scanf("%lf%lf%lf%lf", &a, &b, &h, &m);
  time = 60 * h + m;
  kaku = time * 5.5;
  len = sqrt(a * a + b * b - 2 * a * b * cos(kaku));
  printf("%.10lf", len);
}
