#include <bits/stdc++.h>
using namespace std;
signed main() {
  double A, B, H, M;
  double cm, radA, radB, rad, ten;
  double l2, l60, l12;
  l12 = 12.000000000000000;
  l60 = 60.000000000000000;
  l2 = 2.000000000000000;
  cin >> A >> B >> H >> M;
  radA = l2 * acos(-1.0) * (H + M / l60) / l12;
  radB = l2 * acos(-1.0) * M / l60;
  rad = abs(radA - radB);
  if (rad >= acos(-1.0)) {
    rad = abs(l2 * acos(-1.0) - rad);
  }
  ten = l2 * A * B * cos(rad);
  cm = sqrt(A * A + B * B - ten);
  cout << fixed << setprecision(15) << cm << endl;
  system("pause");
}
