#include <bits/stdc++.h>
int A, B, H, M;
double k, C, c;
int main() {
  scanf("%d %d %d %d", &A, &B, &H, &M);
  H = 30 * H + 30 * M / 60;
  M = 6 * M;
  k = fabs(H - M);
  k = M_PI * k / 180;
  C = A * A + B * B - 2 * A * B * (cos(k));
  c = sqrt(C);
  printf("%.20lf\n", c);
  return (0);
}
