#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 theta1 = M * 60;
  double theta2 = 30 * H + M / 2.0;
  double delta = (theta1 - theta2) / 180.0;
  double C = sqrt(A * A + B * B - 2 * A * B * cos(pi * delta));
  cout << fixed << setprecision(20);
  cout << C << endl;
}
