#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double arg =
      max(6.0 * m - (30.0 * h + 0.50 * m), (30.0 * h + 0.50 * m) - 6.0 * m);
  arg = min(360.0 - arg, arg);
  double rad = arg * acos(-1) / 180.0;
  double x = a * a + b * b - 2.0 * a * b * cos(rad);
  double ans = sqrt(x);
  cout << fixed << setprecision(15) << ans << endl;
  return 0;
}
