#include <bits/stdc++.h>
using namespace std;
int main() {
  double A, B, H, M;
  cin >> A >> B >> H >> M;
  double angle;
  H = (H + (M / 60.0)) * 30;
  M = M * 6.0;
  angle = abs(H - M);
  if (angle > 180) angle = (360.0 - angle);
  angle = M_PI * angle / 180.0;
  double c;
  c = A * A + B * B - (2.0 * A * B * cos(angle));
  c = pow(c, 0.5);
  cout << setprecision(11) << c;
  return 0;
}
