#include <bits/stdc++.h>
using namespace std;
int main() {
  const double pi = 3.14159265358979323846;
  int A, B, H, M;
  double x;
  cin >> A >> B >> H >> M;
  x = A * A + B * B - 2 * A * B * cos(abs(H * pi / 6 - M * pi / 30.0));
  cout << fixed << setprecision(12) << sqrt(x) << endl;
}
