#include <bits/stdc++.h>
float A, B, H, M;
char a[10000000] = {0};
double C_dub, answer;
int main(void) {
  scanf("%f", &A);
  scanf("%f", &B);
  scanf("%f", &H);
  scanf("%f", &M);
  double L_S = H * 30 + M / 2 - 6 * M;
  L_S = abs(L_S);
  printf("%0.15f", sqrt(A * A + B * B - 2 * A * B * cos(L_S / 180 * M_PI)));
}
