#include <bits/stdc++.h>
int main() {
  double A, B, H, M;
  scanf("%lf %lf %lf %lf", &A, &B, &H, &M);
  double thetaH, thetaM, ans2;
  thetaH = 2 * M_PI / 12 * (H + M / 60);
  thetaM = 2 * M_PI / 60 * M;
  ans2 = A * A + B * B - 2 * A * B * cos(fabs(thetaH - thetaM));
  printf("%.20lf\n", sqrt(ans2));
}
