#include <bits/stdc++.h>
int main() {
  long double a, b, h, m;
  long double d1, d2, xs, ys, xl, yl;
  long double PI, dis;
  PI = 3.14159265358979L;
  scanf("%Lf %Lf %Lf %Lf", &a, &b, &h, &m);
  xs = a * (double)sin((PI) * (30 * h + m / 2) / 180);
  ys = a * cos((PI) * (30 * h + m / 2) / 180);
  xl = b * sin((PI) * (6 * m) / 180);
  yl = b * cos((PI) * (6 * m) / 180);
  dis = hypot((xs - xl), (ys - yl));
  printf("%.20Lf", dis);
  return 0;
}
