#include <bits/stdc++.h>
using namespace std;
int main() {
  double A, B, H, M;
  cin >> A >> B >> H >> M;
  static const double pi = 3.141592653589793;
  double rad = 2 * pi * (H / 12.0 + M / 60.0 / 12.0 - M / 60.0);
  double C = sqrt(A * A + B * B - 2 * A * B * cos(rad));
  cout << fixed << setprecision(10);
  cout << C << endl;
}
