#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long A, B, H, M;
  cin >> A >> B >> H >> M;
  long long radH = H * 30 + M * 0.5;
  long long radM = M * 6;
  long long d = max(radH, radM) - min(radH, radM);
  d = min(d, abs(360 - d));
  double as =
      (A * A) + (B * B) - (2 * A * B * cos(d * (3.14159265358979323846 / 180)));
  printf("%.10f", sqrt(as));
}
