#include <bits/stdc++.h>
using namespace std;
int main() {
  double A, B, H, M;
  cin >> A >> B >> H >> M;
  double dif;
  double difradi = 0.0;
  double ans = 0.0;
  dif = abs(30 * (H + M / 60) - M * 6);
  if (dif > 180) dif = 360 - dif;
  difradi = dif * M_PI / 180;
  ans = sqrt(A * A + B * B - 2 * A * B * cos(difradi));
  cout << setprecision(20) << ans << endl;
}
