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

struct pos {
  double x;
  double y;
};

double dist(struct pos a, struct pos b) {
  return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}

int main(int argc, char const *argv[]) {
  int A, B, H, M;
  scanf("%d %d %d %d", &A, &B, &H, &M);

  double ang_h, ang_m;
  ang_h = 2.0 * M_PI * ((H + M / 60.0) / 12.0);
  ang_m = 2.0 * M_PI * (M / 60.0);

  struct pos h, m;
  h.x = A * cos(ang_h);
  h.y = A * sin(ang_h);
  m.x = B * cos(ang_m);
  m.y = B * sin(ang_m);

  printf("%.16lf\n", dist(h, m));

  return 0;
}
